Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors using large scale images #1060

Open
chenyanting1 opened this issue Dec 8, 2024 · 1 comment
Open

Errors using large scale images #1060

chenyanting1 opened this issue Dec 8, 2024 · 1 comment

Comments

@chenyanting1
Copy link

The problem I encountered was that I used tif images with a size of 1g, using cv2.imshow, it showed an error, when I used small images, there was no such error
image
code

import os
os.environ["OPENCV_IO_MAX_IMAGE_PIXELS"] = pow(2, 40).__str__()

import numpy
import cv2

img = cv2.imread('G04002.tif', 1)

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)  # siva slika
cv2.imshow('gray', gray)

vis = img.copy()

ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow('thresh', thresh)

mser = cv2.MSER_create()
#mser = cv2.MSER_create(_min_area=2, _max_area=1000)
regions = mser.detectRegions(thresh)

hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions[0]]
cv2.polylines(vis, hulls, 1, (0, 255, 0))

cv2.imshow('mser', vis)

cv2.waitKey(0)

@asmorkalov
Copy link
Collaborator

OpenCV uses int for matrix size (rows and cols). The OPENCV_IO_MAX_IMAGE_PIXELS limitation was introduced to cover it. If the image dimension is more than 1^31 then OpenCV definitely cannot handle it. It's design limitation and cannot be easily fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants