How to find four coordinates of inner rectangle?

 Réponse acceptée

Michael Haderlein
Michael Haderlein le 3 Fév 2015
Modifié(e) : Michael Haderlein le 3 Fév 2015
vsum=sum(image,1);
hsum=sum(image,2);
top=find(vsum,1,'first');
bottom=find(vsum,1,'last');
left=find(hsum,1,'first');
right=find(hsum,1,'last');

6 commentaires

can you explain?
The edges of the rectangle are the first/last values where the sum of all values is larger than 0. So we sum up along each dimension and search the first/last value which is nonzero.
A comment on top/bottom: You might want to exchange these two as for images, the y axis is reversed.
Image Analyst
Image Analyst le 4 Fév 2015
Modifié(e) : Image Analyst le 4 Fév 2015
Ashwathy's "Answer", which he accepted instead of Michael's, moved here so he can accpet Michael's answer instead of his own:
How to find the coordinates of the inner rectangle of the above figure. I want this for license plate detection.
Michael's reply moved from Ashwathyu's "Answer" to here:
So is the question still open? What exactly do you need anymore? If my answer doesn't work/fit/suffice, please tell us what exactly is the problem. If my answer is fine, please mark it as accepted. This way, nobody will waste time reading through questions which have already been answered.
Thanks!
Michael, your top/bottom is correct - nothing to switch/reverse. For images, like arrays, the top line is 1 and increases from there, so your formula for top will give the correct line (row) number.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown 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!

Translated by