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


0 件のコメント
採用された回答
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
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
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!