how can get coordinate of left and top and bottom and right object of binary Image?

12 ビュー (過去 30 日間)
hi everyone I have an Image that is binary...I want to imcrop a segment of image that contain all of objects. but I want to do this in a way that the rect that I choose be smallest. I think if I have the coordinates of the objects that is in( left and top) of Img and (bottom and right) I can do this. Can you help me? Is there any way?
I mean object that I use a red circle around them in this image.
thanks

採用された回答

Walter Roberson
Walter Roberson 2015 年 5 月 27 日
stats = regionprops(YourImage, 'BoundingBox');
boxes = vertcat(stats.BoundingBox);
lefts = boxes(:,1);
rights = lefts + boxes(:,3);
tops = boxes(:,2);
bottoms = tops + boxes(:,4);
upperleft = [min(lefts), min(tops)];
lowerright = [max(rights), max(bottoms)];
cropat = [upperleft, (lowerright - upperleft)];
  3 件のコメント
Image Analyst
Image Analyst 2015 年 5 月 27 日
It's just indexing to extract it!
croppedImage = binaryImage(upperLeft(2):lowerRight(2), upperLeft(1):lowerRight(1));
jack nn
jack nn 2015 年 5 月 28 日
thanks @Image Analyst and @Walter Roberson. excuse me I am beginner. I really appreciate you for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for USB Webcams についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by