draw oriented rectangle around a blob
显示 更早的评论
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 ?
采纳的回答
更多回答(2 个)
Image Analyst
2022-3-26
1 个投票
See John D'Errico's suite of bounding shapes:
Walter Roberson
2022-3-26
编辑:Walter Roberson
2022-3-26
0 个投票
Note that if you are looking for the angles then regionprops() 'Orientation' will give you the angle of the major axes.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
