How to remove morphological features from an image mask
3 次查看(过去 30 天)
显示 更早的评论
I would like to add the sections resembling circles or ellipses back into the image mask created using the code below. The image mask produced by the code and the desired output are shown below. Does anyone have any recommendations for how to do this?
% Threshold the image using Otsu's method level = graythresh(image); bwimage = im2bw(image,level);
%% Process the ROI
% Create ROI image ROIImage = imfill(bwimage,'holes');
% Find ROI boundary ROIboundaries = bwboundaries(ROIImage); [~,I] = sort(cellfun(@length,ROIboundaries)); % Sort by length of the boundary ROIboundaries = ROIboundaries(I); % Find the largest boundary (ROI) ROIboundary = ROIboundaries{end};
% Mask the image with the ROI [m,n] = size(ROIImage); ROImask = poly2mask(ROIboundary(:,2),ROIboundary(:,1),m,n);
% Zero pixels outside the ROI ROIImage(ROImask==0) = 0; bwimage(ROImask==0) = 0;
% Convert to logical ROIoutputimage = logical(ROIImage);
0 个评论
回答(1 个)
Prasad Mendu
2016-11-23
You can use some relevant inbuilt functions available in MATLAB for Morphological Operations to achieve this. Refer to the documentation links given below to get started on this:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!