Error loading image 7656x6619 [closed]

asked 2018-11-13 17:00:56 -0600

l30 gravatar image

im trying to load 2 images of 150MB and i cant load it someone can helme please?

this is my code, i don´t have errors

    Mat imageRed = imread("images/OrtoImagenTest/band(3).tif", CV_LOAD_IMAGE_GRAYSCALE);
Mat imageNir = imread("images/OrtoImagenTest/band(4).tif", CV_LOAD_IMAGE_GRAYSCALE);
     int rows = imageRed.rows;
int cols = imageRed.cols;
cout <<"rows " <<rows << endl;
cout << "cols " << cols << endl;
if (!imageRed.data || !imageNir.data)
{
    cout << "error al leer las imagenes";
    return -1;
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-11-17 04:42:35.240161

Comments

Well maybe try resizing img and check if your problem is related to the size or if there is somthing else wrong during reading it in. Also check for error messages /logs.

holger gravatar imageholger ( 2018-11-14 13:50:33 -0600 )edit

if i read the image with CV_LOAD_IMAGE_ANYDEPTH i can read the image but the values of each pixel are the same and negative thisa is the code

Mat imageRed = imread(ubicacion+"band(3).tif", CV_LOAD_IMAGE_ANYDEPTH); Mat imageNir = imread(ubicacion+"band(4).tif", CV_LOAD_IMAGE_ANYDEPTH); if (!imageRed.data /|| !imageNir.data/) { cout << "error al leer las imagenes"; return -1; } int rows = imageRed.rows; int cols = imageRed.cols; cout <<"rows " <<rows &lt;&lt;="" endl;="" cout="" &lt;&lt;="" "cols="" "="" &lt;&lt;="" cols="" &lt;&lt;="" endl;="" int="" seccion="rows/3;" int="" cont="0;" cout="" &lt;&lt;="" "seccion="" :"="" &lt;&lt;="" seccion="" &lt;&lt;="" endl;="" float="" sumandvi="0;" to="" chec="" every="" pixel="" inthe="" image="" for="" (int="" row="0;" row="" &lt;="" rows;="" row++)="" {="" for(int="" col="0;" col="" &lt;="" cols;="" col++)="" {="" vec4i="" pixelred="imageRed.at&lt;Vec4i">(row,col ); cout <<"pixel red";

l30 gravatar imagel30 ( 2018-11-14 14:12:54 -0600 )edit

i got this values for each pixel [-971227136, -971227136, -971227136, -971227136]

l30 gravatar imagel30 ( 2018-11-14 14:15:21 -0600 )edit

Ok well i know that pixels must be in range between 0..255 For a color picture you have three of them (each for r,g,b channel) You are reading it in as a greyscale image.

Can you do the same like before but read it in as a color image (just imread with path) If you still see strang pixel values - you picture is most likely corrupt or opencv has problems with the picture format(i dont think so - opencv is pretty versatile) Try open it in another application if possible and check it is not corrupt.

holger gravatar imageholger ( 2018-11-14 14:36:27 -0600 )edit

the picture format is .tiff, i can open the image with windows image editors, this are the images: imageNir :https://mega.nz/#!fsoWXCTY!ntknlYIUIxmDFklyCUlWggcunRTSjNnBu6rRXZ63PdA imageRed: https://mega.nz/#!2kx0iCjK!JQn5TQp2yu...

l30 gravatar imagel30 ( 2018-11-14 15:21:32 -0600 )edit

Hmm dude - i just downloaded your image and immediality got a None object(python) back. Opencv just cannot read in your picture this way.

I did

cv2.imread("band.tif",  cv2.IMREAD_UNCHANGED)

And its fine now. I guess tiff is a uncompressed and raw format. Well i just give a f* about this. I am just a bit annoyed that you did not include this in problem description.

Nvm its not that big of deal but please include relevant information.Anyway i consider this as solved. If you still have problems somehow(i tested on windows) - just convert image to jpg or sth.

Good luck and hf!

holger gravatar imageholger ( 2018-11-14 15:35:52 -0600 )edit