简体   繁体   中英

Rectangular Region Detection in OpenCV Python

I am new to OpenCV and I am seeking help in an algorithm in Python.

I am trying to identify the region in an image where most of the rectangular shapes appear. In particular, I have several images of equal size, with one single rectangle appearing in each image (all these images are stored in the probability_image_array.npy file). I am summing all these images to obtain a single final image ( probabiliy_image.npy ), also shown in the figure below. My task is to find the most prominent rectanguar region in this final image, ie where visibly most of the rectangles are appearing. In the file Figure_1_expected output.png you have an example of the output I am expecting to obain.

Thanks for your help

Figure 1

Figure_1_expected output.png

I suggest thresholding the image, so that the most prominent rectangular region shows up as a binary mask. Followed by findContours and boundingRect you will get the expected output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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