Home > Software design >  OpenCV tiling TIFF image on loading with imread
OpenCV tiling TIFF image on loading with imread

Time:11-08

I have a 32-bit 3-band TIF image that I am trying to load using OpenCV with Python. I'm specifically avoiding GDAL as it is not user-friendly to install on Windows, and this script is targeted at Windows machines.

When I try to load the image with imread ( img = cv2.imread(file, flags=(cv2.IMREAD_UNCHANGED | cv2.IMREAD_ANYDEPTH)) ), and either write it out or imshow it, the 3 bands appear to be tiled, like so: uss_midway

For comparison, rendering in Windows looks like this: windowsmidway So there should be no issue from an OS support perspective.

GIMP Properties for image: Properties pane from GIMP - RGB color, 32-bit gamma floating point

Is there a way to override this behaviour? Is there a known cause to this?

CodePudding user response:

I found a solution. Using the tifffile library in conjunction with scikit-image, I was able to load my TIFFs in a format understandable by OpenCV.

Thus, my load statement became:

img = skimage.io.imread(file,plugin='tifffile')

And the image:

enter image description here

  • Related