How do I select a region of interest across many frames?
1 view (last 30 days)
Show older comments
I want to select a same region interest across many frames, I also want this region to be fixed for all the frames because I want to detect the movement of a particle across these frames. I would really appreciate any assistance. Thank you
0 Comments
Answers (2)
Image Analyst
on 1 Apr 2013
You can specify a region of interest in many ways.
You can interactively draw it using tools like roipoly(), roipolyold(), rbbox(), imrect(), or imfreehand(). You could specify a box by hard coding in the rows and columns. You could do segmentation, for example by intensity thresholding or color segmentation.
However you do it, you have a binary image that is the mask. You can get a frame of your video and then mask it with the ROI mask like this:
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
Here's a snippet you might find useful:
% Display image
subplot(2,2,1);
imshow(rgbImage);
% Have user freehand draw a mask in the image.
uiwait(msgbox('Draw a region with left button down. Double click inside to finish it'));
h = imfreehand();
vertices = wait(h);
% Create a binary mask
mask = createMask(h);
subplot(2,2,2);
imshow(mask, []);
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
subplot(2,2,3);
imshow(maskedRgbImage);
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!