% p. 136: median filter to smooth the noise and
% area closing to enhance the bright objects and make flatter, darker and cleaner the image background.
- imgFiltered{1} = mmareaclose(medfilt2(imgH, [5, 5]), 400); % Hue.
- imgFiltered{2} = mmareaclose(medfilt2(imgS, [5, 5]), 400); % Saturation.
- imgFiltered{3} = mmareaclose(medfilt2(imgV, [5, 5]), 400); % Value.
+ medianFilterWindow = [5, 5];
+ imgFiltered{1} = mmareaclose(medfilt2(imgH, medianFilterWindow), 200); % Hue.
+ % We use an opening fot the saturation because the parasites are darker than the rest of the image.
+ imgFiltered{2} = mmareaopen(medfilt2(imgS, medianFilterWindow), 200); % Saturation.
+ imgFiltered{3} = mmareaclose(medfilt2(imgV, medianFilterWindow), 200); % Value.
imwrite(imgFiltered{1}, '../output/imgHFiltered.png');
imwrite(imgFiltered{2}, '../output/imgSFiltered.png');
imwrite(imgFiltered{3}, '../output/imgVFiltered.png');
-
+
% Shading correction with a Top-hat transformation (p. 673).
% Not in the article -> disable for the moment, not needed.
% imgHFiltered = mmopenth(imgHFiltered, mmsedisk(80, '2D', 'OCTAGON'));
sizeDistribution = zeros(redCellMaxSize, 1);
parfor k = 1:redCellMaxSize
- SE = mmsedisk(k, '2D', 'OCTAGON'); % TODO : tester avec 'euclidean'
+ SE = mmsedisk(k, '2D', 'OCTAGON'); % 'EUCLIDEAN' is more precise.
imgOpened = mmopen(imgFiltered{2}, SE);
A = funVolume(imgOpened);
N = 1 - A / volImg;
%% Regional extrema
% The size of the SE (c) must be equal to the size of red cells (see granulometry below).
- regionalMaxSE = mmsedisk(c, '2D', 'OCTAGON');
+ regionalExtremumSE = mmsedisk(c, '2D', 'OCTAGON');
+ % The functions 'mmregmax' and 'mmregmin' are very time consuming!
parfor i = 1:3
- % This operation is very time consuming!
- M{i} = mmregmax(imgFiltered{i}, regionalMaxSE);
+ if i == 2
+ M{i} = mmregmin(imgFiltered{i}, regionalExtremumSE); % Special case for the saturation component.
+ else
+ M{i} = mmregmax(imgFiltered{i}, regionalExtremumSE);
+ end
end
nucleiSE = mmsedisk(nucleiRadius, '2D', 'OCTAGON');
muS = funVolume(uint8(MHS) .* imgFiltered{2}) / volumeMHS;
TH = im2bw(imgFiltered{1}, double(muH) / 255);
- TS = im2bw(imgFiltered{2}, double(muS) / 255);
+ TS = ~im2bw(imgFiltered{2}, double(muS) / 255);
THS = TH & TS;
%% Extract all sets.
sets = {};
+ labelizedTHS = mmlabel(THS, mmsedisk(1, '2D', 'OCTAGON')); % We choose a SE which is not a point to fill side-by-side areas.
+
n = 1;
- remainingTHS = THS;
- marker = false(size(THS));
while 1
- [i, j] = find(remainingTHS, 1);
- if ~isempty(i)
- marker(i, j) = 1;
- sets{n} = mminfrec(marker, remainingTHS); %#ok<AGROW> % Reconstruction by dilation.
- remainingTHS = remainingTHS & ~sets{n};
- n = n + 1;
- marker(i, j) = 0;
+ set = labelizedTHS == n;
+ if any(any(set))
+ sets{n} = set;
else
break
end
- end
+ n = n + 1;
+ end
%% Check the Hausdorff distance between each set combination by dilation.
for i = 1:length(sets)
%% Parameters
+delete('../output')
mkdir('../output') % Just in case the 'output' directory doesn't exist.
% Hue is unusable for '1305121398'/'0001'
% imageFolder = '1307210661'; % 2.
% imageFolder = '1401063467'; % 3.
% imageFolder = '1405022890'; % 4.
-imageFolder = '1409191647'; % 9.
-% imageFolder = '1412151257'; % 10.
+% imageFolder = '1409191647'; % 9.
+imageFolder = '1412151257'; % 10. (Gamma)
-imageNumber = '0004';
+imageNumber = 'Gamma-0.8-0002';
scaleFactor = 0.6;
imwrite(imgRGBResampled, '../output/imgRGB.png')
imwrite(gtResampled, '../output/gt.png')
+disp('1) Detection of parasites ...')
[THS, c] = DetectionOfParasites(imgRGBResampled);
+
+disp('2) Detection of white cells ...')
[WBC] = DetectionOfWhiteCells(THS, c);
-[Shizonts] = DetectionOfSchizonts(THS, c);
-infectedRedCells = THS - WBC - Shizonts;
-imwrite(infectedRedCells, '../output/infectedRedCells.png')
+disp('3) Detection of schizonts ...')
+[schizonts] = DetectionOfSchizonts(THS, c);
+
+disp('Segmentation of red cells ...')
+SegmentationOfRedCells();
+
+% infectedRedCells = THS - WBC - schizonts;
+% imwrite(infectedRedCells, '../output/infectedRedCells.png')
+
+
+disp('Finished')