How to determine a region of interest and then crop an image using OpenCV

前端 未结 2 1844
小蘑菇
小蘑菇 2020-12-04 00:47

I asked a similar question here but that is focused more on tesseract.

I have a sample image as below. I would like to make the white square my Region of Interest a

2条回答
  •  自闭症患者
    2020-12-04 01:28

    Seeing that the text is the only large blob, and everything else is barely larger than a pixel, a simple morphological opening should suffice

    You can do this in opencv or with imagemagic

    Afterwards the white rectangle should be the only thing left in the image. You can find it with opencvs findcontours, with the CvBlobs library for opencv or with the imagemagick -crop function

    Here is your image with 2 steps of erosion followed by 2 steps of dilation applied: enter image description here You can simply plug this image into the opencv findContours function as in the Squares tutorial example to get the position

提交回复
热议问题