ImageMagick.jl icon indicating copy to clipboard operation
ImageMagick.jl copied to clipboard

Problems with loading 32bit grayscale TIFF

Open alyst opened this issue 4 years ago • 5 comments

The problems are with e.g. the TIFF image attached (generated by Incucyte S3 automatic live imaging microscope). The original TIFF

Fiji does correctly load the image, but ImageMagick.jl (directly or via FileIO.load()) loads it as 1040×1408×2 Array{Gray{N0f32},3} with eltype Gray{Normed{UInt32,32}}. The [:, :, 1] image is all 0xFFFFFFFF, the [:, :, 2] image is all zeros (this looks similar to #99).

alyst avatar Jan 12 '20 16:01 alyst

The issue #173 seems related.

It could be that to read 32bit floating point TIFFs, ImageMagick has to be built with --enable-hdri --with-quantum-depth=32.

My current workaround is to install Python's ImRead, and then

using PyCall
py_imread = pyimport("imread")

fp_img = reinterpret(Float32, py_imread.imread(filename))

alyst avatar Jan 13 '20 15:01 alyst

There's also ImageIO.jl

timholy avatar Jan 13 '20 18:01 timholy

I was looking at ImageIO.jl today. It's definitely promising, but so far there's only wrapping functions around libtiff (yet incomplete -- key var_arg functions like TIFFGetField() are not wrapped), but no readimage() like for PNG.

alyst avatar Jan 13 '20 19:01 alyst

Understood. Nevertheless, if I had to guess, I'd suspect that improving libtiff support would be the fastest route to fixing import of such images in "plain" julia. That said, PyCall works really well.

timholy avatar Jan 13 '20 20:01 timholy

Just a heads up, I've recently written a pure-Julia TIFF parser that should handle 32bit grayscale images such fine: https://github.com/tlnagy/TIFF.jl

It's still technically a WIP (you'll need to git clone it till I register it), but it should already be usable for reading most TIFFs

tlnagy avatar Mar 23 '20 18:03 tlnagy