detect square in image
Afficher commentaires plus anciens

i want to detect square shape only in image. how can i do this using matlab?
Réponse acceptée
Plus de réponses (2)
Sean de Wolski
le 29 Déc 2011
1 vote
Those squares are very well defined.
- Set a less than threshold to make the dark colors true and everything else false. ( BW = I<thresh )
- Perform a connected components analysis ( doc bwconncomp)
- Then regionprops with EulerNumber specified.
- Apply a threshold to the regions matching the EulerNumber ( idx = [stats(:).EulerNumber] == x ) of a sample square.
- Build a new matrix of false. ( BWnew = false(CC.ImageSize))
- Set the indices in the connected components analysis corresponding to the matching EulerNumber to true. ( BWnew(vertcat(CC.PixelIdxList{idx})) = true)
In theory you'll have a mask of the boxes.
Naz
le 29 Déc 2011
Modifié(e) : John Kelly
le 14 Nov 2013
1 vote
I just thought of an alternative idea. Instead of detecting a square, you should register the image (filled form) of interest with the raw image. Then, since you know the coordinates of each square, you can just check the pixels at those coordinates for the white/black values.
Catégories
En savoir plus sur Region and Image Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
