필터 지우기
필터 지우기

draw rectangle on extracted region

조회 수: 3 (최근 30일)
Nataliya
Nataliya 2015년 6월 21일
댓글: Image Analyst 2015년 6월 21일
Hello everyone, I have extracted the moving region by subtracting the video frames. Now I want to draw a rectangle over the extracted part but the problem is the pixels are not connected, thus I can't use regionprops() because it gives several boxes due to disconnected pixels. I have inserted the image where I want to draw rectangle over the extracted moving pendulum area. How can I do this. Please help. Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 6월 21일
vertprofile = any(YourImage>0,1);
bbox_x_low = find(vertprofile, 1, 'first');
bbox_x_high = find(vertprofile, 1, 'last');
horzprofile = any(YourImage>0,2);
bbox_y_low = find(horzprofile, 1, 'first');
bbox_y_high = find(horzprofile, 1, 'last');
The way to proceed from there depends upon how you are going to draw the rectangle.
  댓글 수: 1
Image Analyst
Image Analyst 2015년 6월 21일
By the way, Nataliya, you can use regionprops, you'd just get all the bounding boxes and just use max and min like Walter shows, Or you could call bwconvull() to get just one region then call regionprops(). But unless you're calling regionprops for some other reason, I'd just go with Walter's method.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by