draw rectangle on extracted region
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposte (1)
Walter Roberson
il 21 Giu 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 Commento
Image Analyst
il 21 Giu 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.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!