Error processing large images with openCV

3

I'm trying to render an orthomosaic, the problem is that the image is too large, with other smaller maps I can handle normally, but when I will render a map it greater than the error in the conversion from RGB to HSV, but this error occurs because it could not read the image soon it is trying to convert an empty image, so the error.

This is the initial code and the error displayed is in the RGB to HSV conversion line ...

import cv2
import numpy as np

imageName = "mapa.tif"

imagem = cv2.imread(imageName,cv2.IMREAD_COLOR)
hsv = cv2.cvtColor(imagem, cv2.COLOR_BGR2HSV)

error:

OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor, file /build/opencv-SviWsf/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp, line 3959

Note: Remember that with smaller maps the code works, so I think there might be some memory allocation limit on the cv2.imread function.

Does anyone have any information on this? or do you know how to increase the memory allocation limit for image reading in openCV?

    
asked by anonymous 20.09.2017 / 13:42

1 answer

1

As you've already noted, your problem is that cvtColor is not recognizing the input image, it probably thinks None when expecting an image with at least 3 color channels: image.shape[2] equal to 3 or 4 .

It is strange that the error is only in cvtColor , I would expect that already in imread of this problem.

Anyway, one thing you can do is see what size image your hardware can handle. To do this, you need to check the image size ( image.size ) and what type ( type(image) ). This will know the maximum image size that can be converted.

Hence, you have two approaches that depend on what you want to do with that image. 1) resize the image (% with%) 2) Break the image into smaller parts, convert and then merge again. As images are ndarrays, just use indices to separate the part of the ndarray you want.

    
25.06.2018 / 01:57