how to show img without specific regions

조회 수: 1 (최근 30일)
Lukasz Jarod
Lukasz Jarod 2014년 12월 28일
답변: Image Analyst 2014년 12월 28일
i want to remove some of conected componets and than show original img withaut them.
i'm doing somthing like that
[L Ne]=bwlabel(imagen);
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
height=max(r)-min(r)+1;
width=max(c)-min(c)+1;
[rzedy,kolumny,~]=size(n1);
if(height>width)
n1=zeros(kolumny,rzedy);
n1(:)=255;
end
end
but now i would like to see components that height<width on orginal img witout components that height>width how can i do that??

답변 (1개)

Image Analyst
Image Analyst 2014년 12월 28일
You can use the ismember() function, as shown in my Image Processing Tutorial in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Bascially get the bounding box from regionprops then find where the widths are greater than heights, and use ismember to extract only them. Something like this untested code:
measurements = regionprops(labeledImage, 'BoundingBox');
widths = [measurements.BoundingBox(3)];
heights = [measurements.BoundingBox(4)];
blobsToKeep = find(widths>heights);
keepers = ismember(labeledImage);
% Relabel and remeasure using only these keeper blobs
binaryImage = keepers > 0;
labeledImage = bwlabel(binaryImage);
measurements = regionprops(labeledImage, 'BoundingBox');

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by