how to show img without specific regions
조회 수: 1 (최근 30일)
이전 댓글 표시
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??
댓글 수: 0
답변 (1개)
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');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!