functionValues = [0.38, 800, 32;
0.5, 700, 64;
0.4, 750, 16]
for k = 1 : size(functionValues, 1)
threshold = functionValues(k, 1);
minBlobSize = functionValues(k, 2);
radius = functionValues(k, 3);
burnedAnt = createAntSegmentation(ant, threshold, minBlobSize, radius);
end
function burnedAnt = createAntSegmentation(ant, threshold, minBlobSize, radius)
if ndims(ant) == 3
greyant = rgb2gray(ant);
else
greyand = ant;
end
adaptedAnt = adaptthresh(greyant, threshold, "ForegroundPolarity", "dark");
BW = imbinarize(greyant,adaptedAnt);
BWopen = bwareaopen(~BW, minBlobSize);
se = strel("disk", radius);
BWdilate = imdilate(BWopen, se);
BWfilled = imfill(BWdilate, "holes");
burnedAnt = imoverlay(ant, ~BWfilled, "k");
end