JuliaIO / ImageMagick.jl

Thin Wrapper for the library ImageMagick
Other
53 stars 37 forks source link

Problems with loading 32bit grayscale TIFF #177

Open alyst opened 4 years ago

alyst commented 4 years ago

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 commented 4 years ago

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))
timholy commented 4 years ago

There's also ImageIO.jl

alyst commented 4 years ago

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.

timholy commented 4 years ago

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.

tlnagy commented 4 years ago

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