How to remove morphological features from an image mask
조회 수: 5 (최근 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!