Skip to content

Errors using large scale images #1060

Open
@chenyanting1

Description

@chenyanting1

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions