opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

PYTHON cv2.resize Error “(-215:Assertion failed) !dsize.empty()”

Open josele69 opened this issue 3 years ago • 2 comments

I am trying to resize an image with cv2.resize function in PYTHON3 and I get the following error:

error: OpenCV(4.5.1) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-oduouqig\opencv\modules\imgproc\src\resize.cpp:3688: error: (-215:Assertion failed) !dsize.empty() in function 'cv::hal::resize'

My images are uint16 arrays:

img_ms.shape (4, 57, 62)

img_pan.shape (1, 1140, 1240)

The sample function I am using inside an image pansharpening script is:

downsampled_img_pan = cv2.resize(img_pan, (img_ms.shape[2], img_ms.shape[1]), interpolation = cv2.INTER_AREA)[:, :, np.newaxis]

Thanks!

josele69 avatar Mar 05 '21 19:03 josele69

I dont think will work since you cannot convert a 4D img into 1D like this.

sanketc001 avatar Apr 17 '21 19:04 sanketc001

last dim must be lower than 512. but 1240 > 512

apple55bc avatar Feb 28 '23 02:02 apple55bc