MATLAB Answers


Measuring/scoring rectangularity of shapes

Asked by Alon BenMoshe on 13 Sep 2018
Latest activity Commented on by Alon BenMoshe on 16 Sep 2018
I need to compare and rank (give a score) drawings made by a mechanical device: An ideal rectangle would get the score of 100%, and an arbitrary image would get (say) 10%. See attached examples of drawings I want to rank. The next step of this project would be to modify the device and compare the drawings' grades before and after the modification.
Any ideas? techniques?

1 Answer

Answer by Image Analyst
on 13 Sep 2018

You could do color segmentation (see my File Exchange ) to split the image between black and yellow. Then get a binary image of the black parts and pass it to bwlabel() to count the number of black blobs. 1 would be a solid outline, and a broken outline would of course give more parts. You could also call imopen() on the yellow mask to get the interior yellow "square" and then look at the Solidity from the regionprops() if you look at the yellow blob. You could look at the area fraction of black lines and compare it to what it would be if the lines were all connected. There are other things too, but that's a start.

  1 Comment

Thank you very much for this answer. the file exchange realy helps as well as the suggested way. However, broken or solid outline is only one aspect of bad results, as I'm more interested in rectangle size, line linearity, perpendicularity and parallelity between lines. For example - how can I draw an ideal rectangle (at the correct location...) and compare it with actual result. Thanks again

Sign in to comment.