How to remove morphological features from an image mask
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Prasad Mendu
il 23 Nov 2016
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 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!