How to plot boundary on video frames called inside step() function

2 views (last 30 days)
I am calling some images inside for loop and then doing some processing on those images. After that i am using a step function to display those frames/masks inside a video player. How can i add a boundary to an object inside that frame/mask. Below is the rough sketch of the code.
videoPlayer = vision.VideoPlayer();
maskPlayer = vision.VideoPlayer();
for ii = 1:nfiles
filenameii = [............]
frame= imread(filenameii);
mask = dOB(frame,BackgroundImg);
% some processing on the images
mask= bwareaopen(mask,27);
boundaries = bwboundaries(mask,'noholes');
B=boundaries{1};
Centroid = regionprops(mask,'centroid');
Centroids = cat(1, Centroid.Centroid);
plot(B(:,2),B(:,1),'g','LineWidth',3);
plot(Centroids(:,1), Centroids(:,2), 'r+', 'MarkerSize', 10);
step(videoPlayer,frame);
step(maskPlayer, mask);
end
I want the boundary B to be plotted on the mask image that i am calling inside step function.
P.S: I know how to display it on a figure using hold on and i am using MATLAB. Any guidance will be appreciated.

Answers (0)

Community Treasure Hunt

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

Start Hunting!