From 20d6402c066de15565a43048c5d1e6bf48bf49ba Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Fri, 24 Apr 2015 13:39:27 +0200 Subject: [PATCH] Improve the Schizont detection performance. --- src/DetectionOfParasites.m | 11 ++++------- src/DetectionOfSchizonts.m | 11 +++++++++-- src/SegmentationOfRedCells.m | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/DetectionOfParasites.m b/src/DetectionOfParasites.m index bdb2a51..9dca5c4 100644 --- a/src/DetectionOfParasites.m +++ b/src/DetectionOfParasites.m @@ -13,7 +13,7 @@ function [THS, c] = DetectionOfParasites(imgRGB) imgH = imgHSV(:, :, 1) * 255; % We shift the hue to have the greatest value for the nuclei. - hueShiftValue = 175; % 100 + hueShiftValue = 175; imgH = uint8(mod(255 - imgH + hueShiftValue, 256)); imwrite(imgH, '../output/imgH.png') @@ -23,9 +23,6 @@ function [THS, c] = DetectionOfParasites(imgRGB) imgV = uint8(255 - imgHSV(:, :, 3) * 255); imwrite(imgV, '../output/imgV.png') - % imgV = uint8(imgHSV(:, :, 3) * 255); % The value component isn't used. - % imgH = 255 - imgV; % We use the value component instead of the hue one (just for testing) - % 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. @@ -52,21 +49,21 @@ function [THS, c] = DetectionOfParasites(imgRGB) sizeDistribution = zeros(redCellMaxSize, 1); parfor k = 1:redCellMaxSize - SE = mmsedisk(k, '2D', 'OCTAGON'); + SE = mmsedisk(k, '2D', 'OCTAGON'); % TODO : tester avec 'euclidean' imgOpened = mmopen(imgFiltered{2}, SE); A = funVolume(imgOpened); N = 1 - A / volImg; sizeDistribution(k) = N; end + % TODO : voir diff patternSpectrum = zeros(redCellMaxSize - 1, 1); for k = 1:redCellMaxSize - 1 patternSpectrum(k) = abs(sizeDistribution(k + 1) - sizeDistribution(k)); end - % The paper choose the biggest red cell size among the possible red cell sizes. (FIXME) + % The paper chooses the biggest red cell size among the possible red cell sizes. (FIXME) [m, c] = max(patternSpectrum); - % c = c + 3; nucleiRadius = 5; % Find a way to extract this information from the pattern spectrum histogram. (FIXME) bar(patternSpectrum); diff --git a/src/DetectionOfSchizonts.m b/src/DetectionOfSchizonts.m index 4d94f08..e16327d 100644 --- a/src/DetectionOfSchizonts.m +++ b/src/DetectionOfSchizonts.m @@ -1,4 +1,6 @@ % Inputs: +% THS: +% c: (TODO: should be the average red cell size) function [schizonts] = DetectionOfSchizonts(THS, c) redCellsSE = mmsedisk(c, '2D', 'OCTAGON'); @@ -25,14 +27,19 @@ function [schizonts] = DetectionOfSchizonts(THS, c) %% Check the Hausdorff distance between each set combination by dilation. for i = 1:length(sets) setA = sets{i}; + if isempty(setA) + continue + end dilatedSetA = mmdil(setA, redCellsSE); for j = 1:length(sets) setB = sets{j}; - if setB == setA + if isequal(setB, setA) || isempty(setB) continue end - if (dilatedSetA & setB) == setB %#ok % If B is a subset of A -> there are both in a Hausdorff distance of 2*c. + if (dilatedSetA & setB) == setB % If B is a subset of A -> there are both in a Hausdorff distance of 2*c. schizonts = schizonts | setA | setB; + sets{i} = []; + sets{j} = []; end end end diff --git a/src/SegmentationOfRedCells.m b/src/SegmentationOfRedCells.m index e69de29..fe6292b 100644 --- a/src/SegmentationOfRedCells.m +++ b/src/SegmentationOfRedCells.m @@ -0,0 +1 @@ +function \ No newline at end of file -- 2.45.2