Effacer les filtres
Effacer les filtres

draw rectangle on extracted region

3 vues (au cours des 30 derniers jours)
Nataliya
Nataliya le 21 Juin 2015
Commenté : Image Analyst le 21 Juin 2015
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.

Réponses (1)

Walter Roberson
Walter Roberson le 21 Juin 2015
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 commentaire
Image Analyst
Image Analyst le 21 Juin 2015
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.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by