To retrieve height and width of more than one rectangle rectangle drawn and store it in a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hi Guys I am drawing rectangle in an image using following code
[L Ne]=bwlabel(BW2);
propied=regionprops(L,'BoundingBox');
hold on
for x=1:size(propied,1)
rectangle('Position',propied(x).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
Now if there are two rectangles formed in my image and I want to know their height, width, start and end point and store it in a matrix. (data Of both the rectangles)
I dont know how to do that. plz help me.
2 个评论
Jan
2011-4-4
How did you try to use FINDALL and what exactly means "didn't work"? Please post the code and the error message or description of the different between the results and your expectations.
回答(2 个)
Jan
2011-4-4
hold on
RectH = zeros(1, 10);
for x = 1:10
rectangle('Position', (rand(1, 4) * 0.5), ...
'Tag', 'myRect');
end
Different methods to get the Positions:
Use the vector of handles, if it is available already:
PosList = get(RectH, 'Position');
If you have the AXES handle only:
RectH = findobj(allchild(AxesH), 'flat', 'Type', 'rectangle');
Or:
RectH = findobj(allchild(AxesH), 'flat', 'Tag', 'myRect');
If you have the FIGURE handle only:
RectH = findobj(allchild(FigH), 'Tag', 'myRect');
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!