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
module ParasitesMarker2
open System.Drawing
+open System.Linq
open Emgu.CV
open Emgu.CV.Structure
let darkStain = d_fg.Cmp(median_bg * config.Parameters.darkStainLevel, CvEnum.CmpType.GreaterThan)
darkStain._And(filteredGreenWithoutInfection.Cmp(median_fg, CvEnum.CmpType.LessThan))
- let marker (img: Image<Gray, byte>) (closed: Image<Gray, byte>) (threshold: float) : Image<Gray, byte> =
+ let marker (img: Image<Gray, byte>) (closed: Image<Gray, byte>) (level: float) : Image<Gray, byte> =
let diff = closed - img
let min = ref [| 0. |]
diff.MinMax(min, max, minLocation, maxLocation)
let max = (!max).[0]
- let limitThreshold = 0.1
- let valueThreshold = (*if max < limitThreshold * (median_bg - median_fg) then max / 2. else *) max * threshold
+ let threshold = 0.2 * max
+ let diff' = diff - threshold
+
+ let m = MathNet.Numerics.Statistics.StreamingStatistics.Mean(seq {
+ for m in ImgTools.findMaxima diff' do
+ let p = m.First()
+ yield diff'.Data.[p.Y, p.X, 0] |> float }) + threshold
+
+ let valueThreshold = m * level
diff._ThresholdBinary(Gray(valueThreshold), Gray(255.))
diff
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