[IPOL discuss] IEEE floating point images

Gabriele Facciolo gfacciol at gmail.com
Fri Jun 3 09:26:00 CEST 2011


Hi,
I've just had a nice surprise:
It turns out that PIL (Python Imaging Library) DOES support reading
and writing TIFF_f32 since 2006,
but only for a single channel images  (PIL/TiffImagePlugin.py)

This is good because at least we can use PIL to handle the conversion
of the inputs/outputs of the algorithms.
And as Nicolas said, we can also patch TiffImagePlugin to support
multichannel TIFFs.

Best,
Gabriele

It is very difficult to find f32 tiffs out there, here is one:
https://dl.dropbox.com/u/3957535/village1l.c1.512.disp.tif


from PIL import Image
a =  Image.open('village1l.c1.512.disp.tif')
a.getpixel((100,100))
a.save('k.tif')


On Fri, Jun 3, 2011 at 4:21 AM, Nicolas Limare
<nicolas.limare at cmla.ens-cachan.fr> wrote:
>
> Hi,
>
> > My understanding is that the IPOL io_tiff library is currently limited
> > internally to reading and writing with 8-bit data.
>
> If your are talking about the io_tiff code available on
> http://www.ipol.im/meta/dev/, this code, contributed by Pascal
> Monasse, reads and writes IEEE single-precision data.
>
> > For reading, it uses libtiff's simple TIFFReadRGBAImage function to
> > read the data.  This function reads and converts all data formats to
> > red-green-blue-alpha using 8 bits per component.  The read_tiff_f32
> > function then converts the 8-bit data to 32-bit floating point.
>
> No, it reads with TIFFReadScanline() and writes with TIFFWriteScanline()
> -> http://dev.ipol.im/git/?p=nil/io_tiff.git;a=blob;f=io_tiff.c
>
> I think you are talking about an older io_tiff code, which was used
> for integer images, but is not distributed on IPOL (PNG is the way to
> go with integer images).
>
> > > I am using the reading and writing functions ("write_tiff_f32()")
> > > provided by IPOL. Does anyone if it is fine ?
>
> Pascal wrote it, so he can probably answer your question. Be sure to
> use the real float code from http://www.ipol.im/meta/dev/, not the
> bad 'integer-values-as-float' one.
>
> >> Also, I understand that using "1x8i" or "3x8i" for "input_dtype" in app.py
> >> corresponds to using 8-bit gray-scale or 3x8-bit color images. Does that
> >> mean that all images are converted to 8-bit-kind images?
>
> Yes. All input images received by the ipol demos are converted to
> 8bit, because:
> * 99.99% of the images people have on their computers are integer
>  images (actually, the number is probably 99.999999...);
> * there is no reliable support in the conversion code (either using
>  Python Imaging Library or imagemagick tools) to read or write float TIFF.
>
> >> Does anyone have a simple solution?
>
> * read integer images, because that's what IPOL demos can handle
>  and that's what people will submit
> * convert to float and process float data
> * write float images (TIFF float, Pascal's io_tiff should be OK) *and*
>  approached integer images for www visualization (I think PNG is
>  better, use io_png)
>
> This is a short-term mixed strategy.
>
> If you really need to read float data from the IPOL demos, this is
> impossible until we have reliable TIFF float support in external
> tools. We would need a way to convert any uploaded image (including
> integer jpeg and png) to a TIFF float. Anyone volunteers to contribute
> to PIL and imagemagick?
>
> --
> Nicolas LIMARE - CMLA - ENS Cachan    http://www.cmla.ens-cachan.fr/~limare/
> IPOL - image processing on line                          http://www.ipol.im/
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAk3oRUUACgkQvviFAPpCP08DOwCdFfcTTI/WJ/wBhI4MK4UmOrAH
> r3EAniu9ZkKOTkuh9鈱鴌⼸刞�
> =oDTc
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> discuss mailing list
> discuss at list.ipol.im
> http://tools.ipol.im/mailman/listinfo/discuss


More information about the discuss mailing list