-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Very large image not supported (area > 2^32) #10211
Description
- OpenCV => 3.3.1
- Operating system => Windows 10 Pro (64bit)
Related forum link
http://answers.opencv.org/question/178840/very-very-large-image-causes-issues-with-function-int-type-related/
Detailed description
Large images with an area greater than 2^32 cause crashes or do not work in some functions.
A simple example is the cv::threshold method with Triangle method flag:
The operation size.width *= size.height; is done (in file imgproc/src/thresh.cpp, line 1099), but in the case of large images, this overflows the "small" integer int.
Moreover, images with area greater than 2^30 cannot be opened (see imgcodecs/src/loadsave.cpp, line 65). As a workaround, I just modified the mentioned line with #define CV_IO_MAX_IMAGE_PIXELS((uint64)1 << 40, but this can't be a long term fix.
Suggestions
Maybe using other types (like int64 or size_t) for size-related (or maybe index-related) code may be a good idea.
Maybe this can be activated via a preprocessor directive.