How can I find the coordinates of the four corners in this "square" in Matlab? I tried with corner
, regionprops('Extrema')
and detectMinEigenFeatures
with no luck. The problem is the blue square is not a perfect square, so I need some kind of sharpening edge technique or a more "intelligent" find-corner-algorithm to find them.
How to find coordinates of corners in Matlab?
1.2k views Asked by Jimbo AtThere are 2 answers
Assuming you're doing this in "image" mode, rather than analytically, calculate the distance from the centroid to each pixel on your shape, and then plot this as a function of the angle (i.e. as if you started from the centroid and a horizontal line and then you rotated that line and note the length of that 'radius' at each angle). Your graph should be a curve with 4 local peaks which you can then isolate and trace back to their coordinates.
Or, if the assumption holds that the corners are relatively guaranteed to be close to the image corners, restrict yourself to finding a shape corner in the respective image quadrant by performing the above procedure from the image corner and finding the minimum, and then repeat this 4 times (i.e. for each corner)
Because I'm a nice guy, I've translated the Tasos's explainations into code, check the comments :
RESULTS:
The distance (y-axis) vs angle (x-axis) plot:
The final detection: