Find the orientation of each arbitrary object in an image
Afficher commentaires plus anciens
Hi,
I have an image like this? Does anybody have any idea how can I get the orientation of each object? I know that the objects are not suitable to assign any orientation but at least I learn how can I do that? Actually, I also want to remove some of the objects which have a strange shape.
Thanks

Réponse acceptée
Plus de réponses (2)
Guillaume
le 18 Oct 2019
The structure (or table if you ask for table output) returned by regionprops has a field called 'Orientation' which is the angle of the major axis of an ellipse fitted to the object.
stats = regionprops(yourbwimage, 'Orientation');
5 commentaires
Torkan
le 18 Oct 2019
Guillaume
le 18 Oct 2019
If you want something else than an ellipse fit then you'll have to make the fit yourself. You can see how regionprop does it by looking at its code (edit regionprops make sure you don't modify it!).
I would say that for most of your shapes an ellipse fit would work for finding the orientation of the major axis.
Adam has made a nice demo for you using exactly this method, and it seems to work for all your shapes.
Torkan
le 18 Oct 2019
Image Analyst
le 18 Oct 2019
You can use regionprops to get shape info. One nice one is the circularity. If you want stick-like objects, you do
props = regionprops(binaryImage, 'Perimeter', 'Area', 'Orientation')
allAngles = [props.Orientation]; % Extract all orientation angles into one vector.
histogram(allAngles); % Show distribution of angles.
allAreas = [props.Area]; % Extract all areas into one vector.
allPerimeters = [props.Perimeter]; % Extract all perimeters into one vector.
circularities = allPerimeters .^ 2 ./ (4 * pi * allAreas);
Circular blobs will be close to 1 and tortuous-shaped blobs or stick-shaped blobs will have higher circularity values, like 5 or 10 or more.
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!

