フィルターのクリア

Find out which blob has the pixel location [x,y]?

1 回表示 (過去 30 日間)
Gopichandh Danala
Gopichandh Danala 2017 年 2 月 13 日
コメント済み: Gopichandh Danala 2017 年 2 月 14 日
I have a labelled blob image using bwlabel, I want to find a blob which has the pixel location [x,y] and display it by removing the rest of blobs. Here is the code I wrote, but it doesn't give correct answer, please fix this
[y, x] = ginput(1);
x = round(x);
y = round(y); % here x and y is a location of blob i want to keep
BW = bwlabel(newImgg,4) ; % labelled image contains several blobs
% figure, imshow(BW, [])
props = regionprops(logical(BW),'all');
while(1)
for k = 2:length(props)
if isequal(ismember([x,y],props(k,1).PixelList),[1, 1]);
keeperIndex = k;
break
end
end
break
end
keeperBlobsImage = ismember(BW, keeperIndex);
keeperBlobsImage = imfill(keeperBlobsImage,'holes');
figure, imshow(keeperBlobsImage,[])
Thanks,
Gopi

採用された回答

Walter Roberson
Walter Roberson 2017 年 2 月 13 日
編集済み: Walter Roberson 2017 年 2 月 13 日
BW(y, x) is the blob number when BW is the result of bwlabel(). And you can then proceed to get rid of everything else using the mask BW == BW(y, x)
Note that y is first and then x in indexing.
  5 件のコメント
Gopichandh Danala
Gopichandh Danala 2017 年 2 月 14 日
The problem I found in my code is that
if isequal(ismember([x,y],props(k,1).PixelList),[1, 1]);
This statement in the above code is looking for all x coordinates in props(k,1).PixelList) separately and all y coordinates in props(k,1).PixelList) separately and if both those x and y occur anywhere in x and y column it chooses that blob as the keerBlolb
Gopichandh Danala
Gopichandh Danala 2017 年 2 月 14 日
I understood what you tried to say, It worked Thanks

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by