To assign different color in boundary.
2 views (last 30 days)
Show older comments
Jhilam Mukherjee
on 22 Dec 2013
Commented: Image Analyst
on 9 Nov 2021
I want to outline the boundary of the segment image using bwperim() and get the resultant image i.e boundary.jpg, but my aim is to get an output image which outline the region of segment.jpg with different colors link red or green. How it is possible
0 Comments
Accepted Answer
Image Analyst
on 22 Dec 2013
You can use bwboundaries() and plot() to do that:
hold on;
boundaries = bwboundaries(binaryImage);
numberOfBoundaries = size(boundaries, 1);
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
hold off;
3 Comments
Alex Perrakis
on 9 Nov 2021
pic01=imread("1.tiff");
pic1=im2gray(pic01);
i=1;
boundaries=[];
for i=3:7:69;
pic050=im2gray( imread(i+".tiff") );
%pic50=im2gray(pic050);
newpicture=imsubtract(pic01,pic050);
%imshow(newpicture)
level = graythresh(newpicture);
level = 0.1405;
newbinpic = imbinarize(newpicture,level);
%imshowpair(newpicture,newbinpic,'montage')
newbinpic2=bwpropfilt(newbinpic,'perimeter',1);
% imshowpair(newbinpic2,newpicture,'montage');
boundariesi = bwboundaries(newbinpic2);
boundaries=[boundaries; boundariesi];
binaryImage = 0.6< newbinpic2 & newbinpic2<1;
end
figure; imshow(pic01);
hold on
for k=1:length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:,2);
y = thisBoundary(:,1);
plot(x,y,'r-','Linewidth',2);
end
grid off
This is my code until now
Image Analyst
on 9 Nov 2021
Yeah, you could call getdata() or getsnapshot() to get a frame and then analyze it to get the boundaries. Not sure how "real time" it would be -- how many frames per second -- but you could certainly try it.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!