Borrar filtros
Borrar filtros

draw rectangle on extracted region

3 visualizaciones (últimos 30 días)
Nataliya
Nataliya el 21 de Jun. de 2015
Comentada: Image Analyst el 21 de Jun. de 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.

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Jun. de 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 comentario
Image Analyst
Image Analyst el 21 de Jun. de 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.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by