To assign different color in boundary.

2 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2013-12-22
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 个评论
Alex Perrakis
Alex Perrakis 2021-11-9
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
Image Analyst 2021-11-9
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.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by