remove objects in image that have larger columns than rows
1 view (last 30 days)
Show older comments
Masar Uthaib
on 27 Dec 2019
Commented: Masar Uthaib
on 27 Dec 2019
Hello
how can remove objects in image that have larger columns than rows in RGB
images .
Thank you
2 Comments
Accepted Answer
Image Analyst
on 27 Dec 2019
Use regionprops(), and ismember():
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'BoundingBox');
bb = vertcat([props.BoundingBox]);
% See if column width > height
widths = bb(:, 3);
heights = bb(:, 4);
goodLabelsIndexes = find(widths <= heights); % And discard if widths > heights
% Remove bad blobs
binaryImage = ismember(labeledImage, goodLabelsIndexes);
% Mask the image using bsxfun() function to multiply the mask by each channel individually.
maskedRgbImage = bsxfun(@times, rgbImage, cast(binaryImage, 'like', rgbImage));
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox 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!.jpeg)