how to show img without specific regions
Show older comments
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??
Answers (1)
Image Analyst
on 28 Dec 2014
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');
Categories
Find more on Signal Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!