lets assume that this is the code i used to identify the boundary. I want display the selected boundary in new window else convert this to mask. is it possible.. some one please help me
I = imread('F:\project_matlab\dataset\002.jpg');
BW = im2bw(I, graythresh(I));
[B,L] = bwboundaries(BW,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end

 채택된 답변

Dishant Arora
Dishant Arora 2014년 3월 7일

0 개 추천

b=bwboundaries(BW); % BW being your binary image
mask=false(size(BW));
for i = 1:length(b)
for j = 1:length(b{i})
ind = b{i}(j,:);
mask(ind(1),ind(2))=1;
end
end
figure
imshow(mask)

댓글 수: 5

Ibrahim Thorig
Ibrahim Thorig 2014년 3월 12일
Dear;
Actually I am trying plot this mask in new window. but when i try your method it shows me whole image. i don't want see back ground. I only need the mask area.
thanks for the help
Image Analyst
Image Analyst 2014년 3월 12일
But you have both the binary image and the boundaries. I don't know what you want. If you don't want the "whole image" then what do you want? Dishant's code basically does the same as bwperim() - it gives you an image where the boundaries are white/true/1 and the rest is black/false/0. Can you post an image showing what you want in this "mask area"? Again, the mask area is the same as the binary image, what you call BW, so do you want just one blob out of a group of blobs that define your mask?
Ibrahim Thorig
Ibrahim Thorig 2014년 3월 12일
편집: Ibrahim Thorig 2014년 3월 12일
dear; actually i want extract image from this image.
BW = imfill(BW , 'holes') % will give you desired mask
Image Analyst
Image Analyst 2014년 3월 13일
No need to get boundaries on that image. Simply threshold. The it depends on what you mean by "extract". What does that mean to you? To you mean crop? Do you want the white bar along the bottom of the image also to be included? What about the white torn edge? It can go from simple to complex depending on exactly what you want to do and what kind of images the algorithm can be expected to encounter.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2014년 3월 7일

댓글:

2014년 3월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by