Ask Your Question
0

Load huge image

asked 2018-09-07 03:49:20 -0600

Bleach gravatar image

updated 2018-09-07 13:17:30 -0600

I try to load relativity big image 32000x32000, 1 channel but assertions raised:

Error: Assertion failed (pixels <=> (1<<30)) in> cv::validateInputImageSize, file C:\Lib\opencv\source\opencv\modules\imgcodecs\src\loadsave.cpp, line 74

OpenCV(4.0.0-pre) Error: Assertion failed ((size_t)valueInt == sz) in validateToInt, file C:\Lib\opencv\source\opencv\modules\imgcodecs\src\utils.cpp, line 48

imread_('e:/0/33333b.bmp'): can't read data: OpenCV(4.0.0-pre) C:\Lib\opencv\source\opencv\modules\imgcodecs\src\utils.cpp:48:  error: (-215:Assertion failed) (size_t)valueInt == sz in function 'validateToInt'

However we can:

Mat m(65000, 40000, CV_8U);

 uint64 i, n = (uint64)m.rows*m.cols;
 for( i = 0; i < n; i++ )
     m.data[i] = (uchar)(i & 255);

cv::threshold(m, m, 127, 255, cv::THRESH_BINARY);
imwrite("e:/0/ttt.jpg", m);

and it works fine. This means we cant load image bigger 1 Gigapixel (UPD. by imread), but able to process and save it?

edit retag flag offensive close merge delete

Comments

consider this

32000   32000   1024000000  x 3 3072000000  
65000   40000   2600000000  x 1 2600000000

probably you can't save if your Mat defined

Mat m(32000, 32000, CV_8UC3);
sturkmen gravatar imagesturkmen ( 2018-09-07 05:42:18 -0600 )edit

@sturkmen. Sory, I make mistake. It was 32000x32000, 3 channel image, but I loaded it as grayscale

m1 = imread("e:/0/33333b.bmp", IMREAD_GRAYSCALE);

probably you can't save if your Mat defined

No, we can. (Win 10 x64)

Bleach gravatar imageBleach ( 2018-09-07 13:25:58 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-09-07 13:50:11 -0600

Eduardo gravatar image

This is the limit in the code CV_IO_MAX_IMAGE_PIXELS.

You can try to increase the value.

edit flag offensive delete link more

Comments

1

it seems simply increasing value will not work see https://github.com/opencv/opencv/blob...

sturkmen gravatar imagesturkmen ( 2018-09-07 14:09:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-07 03:49:20 -0600

Seen: 3,179 times

Last updated: Sep 07 '18