使用“error:( - 1515)ssize.area()>的大图像上的OpenCV调整大小失败函数cv :: resize中的0 [英] OpenCV resize fails on large image with "error: (-215) ssize.area() > 0 in function cv::resize"

查看:2513
本文介绍了使用“error:( - 1515)ssize.area()>的大图像上的OpenCV调整大小失败函数cv :: resize中的0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenCV 3.0.0和Python 3.4.3来处理非常大的RGB图像(107162,79553,3)。我正在尝试使用以下代码调整大小:

I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code:

import cv2
image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)

我收到此错误消息:

cv2.error:C:\ openncv-3.0.0\source \modules\imgproc\src\imgwarp.cpp:3208:错误:(-215)ssize.area()> 0 in function cv :: resize

I had this error message coming up :
"cv2.error: C:\opencv-3.0.0\source\modules\imgproc\src\imgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize"

我确定图像数组中有图像内容,因为我可以保存它们是jpg格式的小瓷砖。当我尝试仅调整图像的一小部分时,没有问题,我最终得到了正确调整大小的图像。 (拿一个相当大的块(50000,50000,3)仍然不起作用,但它可以在(10000,10000,3)块上工作)

I'm certain there is image content in the image array because I can save them into small tiles in jpg format. When I try to resize just a small part of the image, there is no problem and I end up with correctly resized image. (Taking a rather big chunk (50000,50000,3) still won't work, but it will work on a (10000,10000,3) chunk)

I我想知道是什么原因导致这个问题以及如何解决这个问题?

I'm wondering what could cause this problem and how I can solve this?

谢谢

推荐答案

事实证明问题来自 modules\imgproc\src\imgwarp.cpp中的一行

CV_Assert( ssize.area() > 0 );

当要调整大小的图像的行和列的乘积大于2 ^ 31时,ssize .area()导致负数。这似乎是OpenCV中的一个错误,希望在将来的版本中修复。临时解决方法是使用此行注释掉构建OpenCV。虽然不理想,但它对我有用。

When the product of rows and columns of the image to be resized is larger than 2^31, ssize.area() results in a negative number. This appears to be a bug in OpenCV and hopefully will be fixed in the future release. A temporary fix is to build OpenCV with this line commented out. While not ideal, it works for me.

我刚刚发现上述情况仅适用于宽度大于身高的图像。对于高度大于宽度的图像,它是导致错误的以下行:

And I just recently found out that the above applies only to image whose width is larger than height. For images with height larger than width, it's the following line that causes error:

CV_Assert( dsize.area() > 0 );

所以这也需要注释掉。

So this has to be commented out as well.

这篇关于使用“error:( - 1515)ssize.area()>的大图像上的OpenCV调整大小失败函数cv :: resize中的0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆