Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ColHAX_Image_Segmentation/segmentImageHAX.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (50 sloc)
1.58 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [BW,maskedImage] = segmentImageHAX(X) | |
%segmentImage Segment image using auto-generated code from imageSegmenter app | |
% [BW,MASKEDIMAGE] = segmentImage(X) segments image X using auto-generated | |
% code from the imageSegmenter app. The final segmentation is returned in | |
% BW, and a masked image is returned in MASKEDIMAGE. | |
% Auto-generated by imageSegmenter app on 21-Jun-2022 | |
%---------------------------------------------------- | |
% Idouble = im2double(X); | |
% LL=quantile(Idouble(:),0.1); | |
% UL=quantile(Idouble(:),0.9); | |
% X = imadjust(X,[LL UL],[]); | |
% Adjust data to span data range. | |
X = imadjust(X); | |
% 2*floor(size(X)/16)+1 | |
N=16; | |
T = adaptthresh(X,0.6,'NeighborhoodSize',2*floor(size(X)/N)+1,'Statistic','gaussian','ForegroundPolarity','bright'); | |
% Threshold image - adaptive threshold | |
% BW = imbinarize(X, 'adaptive', 'Sensitivity', 0.6000, 'ForegroundPolarity', 'bright'); | |
BW = imbinarize(X, T); | |
% Invert mask | |
BW = imcomplement(BW); | |
% Dilate mask with disk | |
radius = 4;%3 | |
decomposition = 0; | |
se = strel('disk', radius, decomposition); | |
BW = imdilate(BW, se); | |
%Erode mask with disk | |
radius = 4; | |
decomposition = 0; | |
se = strel('disk', radius, decomposition); | |
BW = imerode(BW, se); | |
% Open mask with disk | |
radius = 9; | |
decomposition = 0; | |
se = strel('disk', radius, decomposition); | |
BW = imopen(BW, se); | |
%% | |
% Close mask with disk | |
% radius = 1; | |
% decomposition = 0; | |
% se1 = strel('disk', radius, decomposition); | |
% BW = imclose(BW, se1); | |
% radius = 5; | |
% decomposition = 0; | |
% se = strel('disk', radius, decomposition); | |
% BW = imerode(BW, se); | |
% Create masked image. | |
maskedImage = X; | |
maskedImage(~BW) = 0; | |
end | |