fill inside a boundary
19 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
i have two frames of images with time delay. i specified a boundary in first frame around an object. So i have the position of the boundary. I want to fill inside the boundary with values from the second frame. any idea?
0 个评论
采纳的回答
Alex Taylor
2011-6-8
Hi Azarm,
A good way to solve this problem will be to obtain a logical image that represents the boundaries of the first frame. Once you have this logical image, you can use logical indexing to fill the region inside the boundary with specified values.
a = rand(200);
% Create a logical image that defines a rectangular boundary.
mask = false(size(a));
mask(10:100,10:100) = true;
% Assign a fill value of 40 to all pixels within the boundary
a(mask) = 40;
figure, imagesc(a)
I'm not sure whether you have the Image Processing Toolbox. If you do, you might be interested in looking at the function poly2mask.
doc poly2mask
This function is useful in moving from X,Y definitions of boundaries to a logical image representation of the mask.
更多回答(1 个)
Sean de Wolski
2011-6-8
M = imfill(BoundaryImage,'holes'); %Assuming boundary is connected. Else use poly2mask
I1(M) = I2(M); %Set mask portion of first image to that of second.
If you don't want to fill the boundary itself:
M = xor(BoundaryImage,imfill(BoundaryImage,'holes'));
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!