a b/Image Segmentation/Image Utility Functions/extraction/maskCreationOtsu.m
1
function [ masks ] = maskCreationOtsu(segmentedImages)
2
%noduleExtractionOtsu extract the nodule based on the segmented images
3
%   hardcoded values, you might need to change them in the future
4
%
5
%   param orgImage
6
%       the original image that will be segmented
7
% 
8
%   param segmentedImages
9
%       a cell array of each image segmentation
10
% 
11
    %% Pre-process
12
    %Get the number of segmentations
13
    segTotal = 1;
14
    
15
    %total class
16
    totalClass = 5;
17
    
18
    %set up cell array for images
19
    masks = cell(1,1);
20
    
21
    x = 1;
22
    
23
    %% extract nodule
24
    for i=1:segTotal
25
        
26
        %get segmented image
27
        s = segmentedImages{i};
28
29
        %iterate through classes
30
        for j=2:totalClass
31
            
32
            %create temp image
33
            tempImage = s;     
34
            %erase background pixels
35
            for e=1:j-1
36
                tempImage(s == e) = 0;
37
            end            
38
            
39
            %remove any components that aren't part of the nodule and save
40
            %the nodule as a binary image
41
            tempImage = im2bw(removeDisjointStructures(tempImage));
42
            
43
            %fill the holes and save the mask
44
            masks{x} = imfill(tempImage,'holes');   
45
            
46
            %increment position in image array
47
            x = x + 1;
48
49
        end
50
        
51
    end
52
53
54
end
55