I have plotted a image using imshow(Image). Now I placed "hold on" command. I have drawn the boundaries of each object in the image as given in code below. How can I capture the new image with boundaries drawn in the plot into an array of pixels ??
4 views (last 30 days)
Show older comments
[B,L,N] = bwboundaries(Image);
imshow(Image); hold on;
for k=1:length(B),
boundary = B{k};
if(k > N)
plot(boundary(:,2),boundary(:,1),'g','LineWidth',2);
else
plot(boundary(:,2),boundary(:,1),'r','LineWidth',2);
end
end
0 Comments
Accepted Answer
Image Analyst
on 27 May 2014
Just assign them to an image in a loop inside the loop:
for k=1:length(B)
boundary = B{k};
for k = 1 : size(boundary, 1)
x = boundary(:,2); % Column
y = boundary(:,1); % Row
boundaryImage(y, x) = 255;
end
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!