Effacer les filtres
Effacer les filtres

Drawing a line down the middle of an object?

4 vues (au cours des 30 derniers jours)
Alex Mason
Alex Mason le 18 Août 2011
I have this image:
ignore the little specks, I have already got a method of removing them and leaving just the big block of white.
Is it possible to then trace a rough line down the middle of that object? and then replace that object with the line? It doesnt have to follow any kind of curvature, just a THIN straight line roughly following the angle and length. Also it could be helpful if the line was assigned a random colour.
I know regionprops will get me the centroid and there is an orientation property which seems to be the angle, but I cant be sure. Region props gave about 77 for orientation which looks about right. Is extent going to be the right thing to use with regionprops?

Réponses (1)

BF83
BF83 le 18 Août 2011
Hi,
you could first calculate the centroid of your white object and then use princomp to get the object's eigenvector related to the greatest eigenvalue. This vector along with the centroid should allow you to plot your line.

Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by