From 785a7ea4885e87d76f0b1fb1c715230a08389558 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Wed, 23 Dec 2015 12:29:51 +0100 Subject: [PATCH] Change the way the parasites are detected. --- Parasitemia/Parasitemia/Config.fs | 4 ++-- Parasitemia/Parasitemia/ParasitesMarker2.fs | 14 +++++++++++--- Parasitemia/Parasitemia/Program.fs | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Parasitemia/Parasitemia/Config.fs b/Parasitemia/Parasitemia/Config.fs index 3e3a06c..5cf392c 100644 --- a/Parasitemia/Parasitemia/Config.fs +++ b/Parasitemia/Parasitemia/Config.fs @@ -23,11 +23,11 @@ type Parameters = { maxDarkStainRatio: float stainArea: float // Factor of a RBC area. 0.5 means the half of RBC area. - stainLevel: float // [0, 1] + stainLevel: float // [0, 2] maxStainRatio: float // [0, 1] infectionArea: float // Factor of a RBC area. 0.5 means the half of RBC area. - infectionLevel: float // [0, 1] + infectionLevel: float // [0, 2] parasitePixelsRequired: int standardDeviationMaxRatio: float // The standard deviation of the pixel values of a cell can't be greater than standardDeviationMaxRatio * global standard deviation diff --git a/Parasitemia/Parasitemia/ParasitesMarker2.fs b/Parasitemia/Parasitemia/ParasitesMarker2.fs index 6afef44..42645b4 100644 --- a/Parasitemia/Parasitemia/ParasitesMarker2.fs +++ b/Parasitemia/Parasitemia/ParasitesMarker2.fs @@ -1,6 +1,7 @@ module ParasitesMarker2 open System.Drawing +open System.Linq open Emgu.CV open Emgu.CV.Structure @@ -30,7 +31,7 @@ let find (filteredGreen: Image) (filteredGreenFloat: Image) (closed: Image) (threshold: float) : Image = + let marker (img: Image) (closed: Image) (level: float) : Image = let diff = closed - img let min = ref [| 0. |] @@ -40,8 +41,15 @@ let find (filteredGreen: Image) (filteredGreenFloat: Image float }) + threshold + + let valueThreshold = m * level diff._ThresholdBinary(Gray(valueThreshold), Gray(255.)) diff diff --git a/Parasitemia/Parasitemia/Program.fs b/Parasitemia/Parasitemia/Program.fs index 781d9ad..25c707d 100644 --- a/Parasitemia/Parasitemia/Program.fs +++ b/Parasitemia/Parasitemia/Program.fs @@ -73,11 +73,11 @@ let main args = maxDarkStainRatio = 0.1 infectionArea = 0.012 // 1.2 % - infectionLevel = 0.2 + infectionLevel = 0.85 parasitePixelsRequired = 1 stainArea = 0.08 - stainLevel = 0.1 + stainLevel = 0.85 maxStainRatio = 0.12 // 12 % standardDeviationMaxRatio = 0.55 -- 2.43.0