opencv / opencv/opencv-python

Errors using large scale images

Open
#1,060 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.4k
Forks
1k
Avg merge
22h 17m
Merged PRs (30d)
3

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python example using cv2.imread, cv2.cvtColor, cv2.imshow, thresholding, and MSER on the referenced 1 GB TIFF, then compare its behavior with a smaller image. Capture the exact error and determine which operation fails; done means the large-image workflow has a reproducible diagnosis and a verified correction or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
opencv, python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.