Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load() on a TIFF image returns all 0xffff #99

Closed
kbarbary opened this issue Jun 7, 2017 · 5 comments
Closed

load() on a TIFF image returns all 0xffff #99

kbarbary opened this issue Jun 7, 2017 · 5 comments

Comments

@kbarbary
Copy link

kbarbary commented Jun 7, 2017

I have a few images I'm trying to read where load() returns an array of all Grey{N0f16}(1.0), but this doesn't seem to be the true file contents when read with other tools. An example image is here: https://www.dropbox.com/s/lelfacepaxvaf6w/testcase.tif?dl=0

julia> using Images

julia> img = load("testcase.tif")
256×256 Array{Gray{N0f16},2}:
 Gray{N0f16}(1.0)  Gray{N0f16}(1.0)    Gray{N0f16}(1.0)  Gray{N0f16}(1.0)
 Gray{N0f16}(1.0)  Gray{N0f16}(1.0)     Gray{N0f16}(1.0)  Gray{N0f16}(1.0)
 
julia> all(img .== Gray{N0f16}(1.0))
true

julia> using ImageMagick

julia> ImageMagick.libversion
v"6.8.9"

julia> Pkg.installed("ImageMagick")
v"0.4.0"

julia> versioninfo()
Julia Version 0.6.0-rc2.0
Commit 68e911b (2017-05-18 02:31 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

In Python, I can load the same image with cv2, and get the correct shape of (256, 256, 4) and non-constant data:

In [1]: import cv2

In [4]: img = cv2.imread("testcase.tif", -1)

In [5]: img.shape
Out[5]: (256, 256, 4)

In [6]: img[0:3, 0:3]
Out[6]: 
array([[[12181, 13224, 13839,  9250],
        [12251, 13337, 13836,  9279],
        [12312, 13407, 13951,  9316]],

       [[12033, 13128, 13720,  9271],
        [12060, 13093, 13628,  9350],
        [11967, 13088, 13505,  9414]],

       [[11627, 12659, 13098,  9057],
        [11770, 12823, 13210,  9163],
        [11796, 12774, 13330,  9244]]], dtype=uint16)

I suppose this might be a libmagickwand problem, but any advice would be appreciated!

@timholy
Copy link
Member

timholy commented Jun 10, 2017

I think it's mostly an ImageMagick issue, but TIFF is a pretty complicated format. I don't have any great ideas, but a couple of options I thought of:

@timholy
Copy link
Member

timholy commented Jun 10, 2017

I should note that I tested several non-Julia applications, and only ImageJ handled the file properly.

@bjarthur
Copy link
Member

i've heard libtiff is great. might be worth making a julia wrapper for it if one doesn't already exist.

@kbarbary
Copy link
Author

Thanks for taking a look Tim, and thanks for the pointers!

@ViralBShah
Copy link
Contributor

There's also https://github.com/tlnagy/TiffImages.jl. Closing since this seems to be an upstream issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants