Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting a corner of an object on a picture

Is there any algorithm to detect a corner of an object on a picture? I have a list of pictures that look like this:

Top left
enter image description here

Bottom right
enter image description here

Now on picture 1 I expect top-left corner, on picture 2 I expect bottom-right, etc.

The algorithm that I need should "ensure" that the image on the picture is definitely top-left / bottom-right / etc (not just a noise, for example like on the picture below) and if it is - to return the X and Y of the corner.

The additional problem is there could be some noise on the picture as in case of picture with the bottom right corner. One more problem is that the picture of the corner can be slightly rotated.

Slightly rotated corner

enter image description here

UPD I should also make sure the image is the picture of the corner that I expect, because the image can look like this:

Noise

enter image description here

like image 366
Andrew Kaplanovsky Avatar asked Nov 20 '25 08:11

Andrew Kaplanovsky


1 Answers

I would start in the corner of the image and then loop through the pixels to find the white pixel that is closest to the corner. Then when you find a white pixel, use the flood-fill algorithm to count how many contiguous white pixels you see. If this pixel count is above your noise threshold (maybe 20 pixels?), then consider this pixel as your corner. This should handle images that are slightly rotated.

like image 100
David Avatar answered Nov 22 '25 20:11

David