get pixel index from region props
7 ビュー (過去 30 日間)
古いコメントを表示
If someone help or try help to me ,I'll be so thankful : as shown in the image , I used 'regionprops' function to divide it into five regions. I want to copy any region (say the second region)from this image and put in a new image which has the same size as original image ,how can I get the pixel indices of that region . thank you.
2 件のコメント
Benjamin Drewry
2019 年 4 月 9 日
this is how I do it, but there are probably better ways. I.e. to separate out the 'jacket' region of the matlab provided pout image
img=imread('pout.tif');
mask=img>130;
bwlabel(mask);
figure(); imagesc(ans);
stats=regionprops(mask, 'all');
bkdg=zeros(img);
y=stats(25).PixelList(:,2);
x=stats(25).PixelList(:,1);
for i=1:length(I)
bkdg(y(i),x(i))=1;
end
figure(); imagesc(bkdg);
final=double(img).*bkdg;
figure(); imagesc(final);
Image Analyst
2019 年 4 月 9 日
Benjamin, please fix the code (so it at least runs), and put it down in the official "Answers" section, not up here in the comments section where we ask posters for additional clarification.
採用された回答
Image Analyst
2015 年 6 月 12 日
You can do that, but it's not the most efficient way, so I won't go into it (besides, it's more complicated). The way you want to do it is with ismember(). You use your labeled image and create the 5 new images with ismember
[labeledImage, numRegions] = bwlabel(binaryImage);
binaryRegion1 = ismember(labeledImage, 1) > 0;
binaryRegion2 = ismember(labeledImage, 2) > 0;
binaryRegion3 = ismember(labeledImage, 3) > 0;
binaryRegion4 = ismember(labeledImage, 4) > 0;
binaryRegion5 = ismember(labeledImage, 5) > 0;
3 件のコメント
Image Analyst
2015 年 6 月 17 日
majed's "Answer" moved here:
thanks a lot , your technique works good . but how can i remove any region from the original image and put in zeros image(with the same size as original one) in the same position(indices) as the original one.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!