-
Notifications
You must be signed in to change notification settings - Fork 0
/
SegmentShoots.m
36 lines (30 loc) · 992 Bytes
/
SegmentShoots.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function binaryMask = SegmentShoots(inputImage, maxIslandNumPixels, segmentPlantFirst, maxIslandNumPixelsPlant)
%SegmentShoots Computes the binary mask for shoots in the image, using color
%thresholding in RGB, YCBCR, and LAB color spaces.
% After segmentation, small islands of size maxIslandNumPixels are
% removed.
if nargin < 2
maxIslandNumPixels = 100;
end
if nargin < 3
segmentPlantFirst = true;
end
if nargin < 4
maxIslandNumPixelsPlant = 50;
end
if(segmentPlantFirst)
plantMask = SegmentPlant(inputImage, maxIslandNumPixelsPlant);
inputImage = uint8(plantMask) .* inputImage;
end
binaryMask = createMaskShootsHSVorig(inputImage);
binaryMask = imclearborder(binaryMask, 8);
binaryMask = bwareaopen(binaryMask, maxIslandNumPixels);
% close all
% imshow(imageHist)
% figure
% imshow(inputImage)
% figure
% imshow(imageHist)
% figure
% imshow(binaryMask)
end