Can't read UAV .tiff images

Why do I get this type of errors?

[ WARN:0] OpenCV TIFF: TIFFRGBAImageOK: Sorry, can not handle images with 64-bit samples
Error!
imread_('/home/mike/Desktop/test_code/IMAGES/UAV_image.tif'): can't read data: OpenCV(3.4.14) /tmp/pip-req-build-m7h7rfem/opencv/modules/imgcodecs/src/grfmt_tiff.cpp:483: error: (-215:Assertion failed) ((uint64_t)tile_width0 * tile_height0 * ncn * std::max(1, (int)(bpp / bitsPerByte)) < MAX_TILE_SIZE) && "TIFF tile size is too large: >= 1Gb" in function 'readData'

and after that, this:

cv2.error: OpenCV(3.4.14) /tmp/pip-req-build-m7h7rfem/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

what exactly you dont understand about the error msg ?
it cant do what you wanted, period.

either convert it, or use a different library

1 Like

That’s what I am implying… How do I load the ~ 2 GB .tiff file I am trying? What modifications should I do?

Here is the error:

self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

What should I change?

iirc, there is already a 2gb size limit in the tiff code (apart from the 64bit problem)

can you try to convert it using a program like imagemagic or gimp ?
(there’s nothing to convert within opencv, if you cant import it)
((also, there might be better python libs for reading tiff, than opencv))

1 Like

I am confused! imagemagic and gimp are for convert the image, right? But I have the problem of importing it first! So, what should I do? Also, in the past I have opened ~ 2.1 GB .tiff. But the .tiff image I am trying to open now is the result of calculations of different images. For instance: (image1 * 2)/((image2)**3)

try to save it in a different format, that you can read from opencv

1 Like

I stored it as .jpg (filesize = 1.9 GB). I tried to loaded, again the same error…

It gives me error on this line:

self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

if it still says empty(), it was not loaded.

check np.shape(img) after loading

1 Like

use this, if you need to handle that TIFF file as is.

2 Likes

how / where do you do this ?

also, what kind o “pixl format” does your imag have, now ? does 64bit mean double ? (no support for int64 images in opencv)

1 Like

Ok this is the part that I load the image:

frame = cv2.imread(path, cv2.IMREAD_UNCHANGED)
self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

I changed to this:

frame = tiff.imread(path)
self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

And I get this error (either I use .tiff or .jpg file):

    self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(3.4.14) /tmp/pip-req-build-m7h7rfem/opencv/modules/imgproc/src/color.simd_helpers.hpp:88: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 1

What should I do??

@berak: Yes I think they are double64.

As I said before the .tiff image that I use, is the output of calculations of another 2 or 3 .tiff files…

Also I did this change:

This:

self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

to this:

self.img = cv2.cvtColor(frame, cv2.IMREAD_UNCHANGED)

And I get this

  File "code.py", line 412, in getFrame
    self.img = cv2.cvtColor(frame, cv2.IMREAD_UNCHANGED) 
cv2.error: OpenCV(3.4.14) /tmp/pip-req-build-m7h7rfem/opencv/modules/imgproc/src/color.cpp:352: error: (-206:Bad flag (parameter or structure field)) Unknown/unsupported color conversion code in function 'cvtColor'
1 Like

wrong flag

well, in the end, you cannot convert a single channel image to rgb …

1 Like

So, what do you suggest?

do you have any control how the images are generated ?

UAV tiff is something meaningless. what hw/sw saves your image ?

1 Like

there must be an image sensor, and sotware running that

1 Like

Yes, but the images that I am trying now are made via calculations on the images that I got from the UAV/drone. The original .tiff images gathered from the drone open without any problem. The problem come with the .tiff images that I have made through python code.
For instance I have an RGB UAV .tiff image. I divide it on the 3 channels, Red.tiff, Blue.tiff, Green.tiff and I make the output.tif ( = Red/(Blue*2) ). The output.tiff does not open. The Red.tiff, Blue.tiff, Green.tiff open…

Any idea? How to fix that? If I only want to store the image with

cv2.cvtColor(frame, cv2.IMREAD_UNCHANGED) what should I put as a flag? Or better how not to use cv2.cvtColor if possible and what modification to make in the above code in order to achieve this? Info: The .tiff image I am trying to load and display is black/white and have range of colors in pixels: 0 to 1. Can this cause the problem? QGIS tool displays just fine!

I have the same problem