简体   繁体   English

如何使用OpenCV找到最大的空矩形?

[英]How to find the largest empty rectangle using OpenCV?

I need to find the coordinates of the largest empty rectangle in a PNG image. 我需要找到PNG图像中最大的空矩形的坐标。 The rectangle should consist of light colors (if that is too difficult, white pixels only are fine) and should be axis-oriented. 矩形应该由浅色组成(如果太难,白色像素很好)并且应该是轴向的。

I am new to computer vision and I found out about OpenCV, I am currently using the python interface to it and started tackling this problem with the SimpleBlobDetector interface, but it gives me only the center of the Blob with a certain radius. 我是计算机视觉的新手,我发现了OpenCV,我目前正在使用它的python接口,并开始使用SimpleBlobDetector接口解决这个问题,但它只给出了具有一定半径的Blob的中心。

Can anyone point me in the right direction for this? 任何人都能指出我正确的方向吗?

EDIT: I need to do this with a regular colored PNG image, not a binary matrix 编辑:我需要使用常规彩色PNG图像,而不是二进制矩阵

You can use a contour extractor , with the given point list you can check the size of the rectangle by checking the sizes of the lists, assuming that all the rectangles are parallel to the cardinal axis. 您可以使用轮廓提取器 ,使用给定的点列表,您可以通过检查列表的大小来检查矩形的大小,假设所有矩形都与基本轴平行。 If not you need to compute the distance of a pixel and the next for all the pixels in the contour list by using the x and y coordinates on each. 如果不是,则需要通过使用每个像素上的xy坐标来计算轮廓列表中所有像素的像素距离和下一个像素的距离。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM