draw oriented rectangle around a blob
Ältere Kommentare anzeigen
function y=cadre(x)
info = regionprops(x,'Boundingbox') ;
imshow(x)
hold on
for k = 1 : length(info)
BB = info(k).BoundingBox;
rectangle('Position', [BB(1),BB(2),BB(3),BB(4)],'EdgeColor','g','LineWidth',1) ;
end
I am using this code with a segmented image in input, and I have this result :
input output 
I would like the rectangles to be the smallest and with the same orientation as the objects, to get the angles for exemple.
How can I modify my code ?
Akzeptierte Antwort
Weitere Antworten (2)
Image Analyst
am 26 Mär. 2022
1 Stimme
See John D'Errico's suite of bounding shapes:
Walter Roberson
am 26 Mär. 2022
Bearbeitet: Walter Roberson
am 26 Mär. 2022
0 Stimmen
Note that if you are looking for the angles then regionprops() 'Orientation' will give you the angle of the major axes.
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
