How to detect the corners of a square in a binary image
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have a binary image of white square with slightly rounded corner on a black background. I need to get the coordinates of all 4 corners. I tried something like that:
[rows, columns] = find(BW);
topRow = min(rows)
bottomRow = max(rows)
leftColumn = min(columns)
rightColumn = max(columns)
This doesn’t always work because the square doesn’t always have right angles.
example iamge.
![T1_6.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195180/T1_6.jpeg)
0 Kommentare
Antworten (2)
Yash Ubale
am 19 Nov. 2018
Hello,
Try using Hough transform to find lines in the image. After finding the lines, find the left-most, right-most, top-most and bottom-most lines. When you get these lines, just find their intersections to find the four corners of the square. Before doing so, I would suggest to erode the image with 'square' structuring element of width say 75, to remove the noise around the square.
Hough transform - https://www.mathworks.com/help/images/ref/hough.html
0 Kommentare
Image Analyst
am 19 Nov. 2018
See my attached shape recognition demo. It will show you how you can locate vertices by finding boundaries and plotting distances of the boundary points from the centroid and then looking for peaks.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Feature Detection and Extraction finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!