* Remove the 'DoG' filter.
[master-thesis.git] / Parasitemia / Parasitemia / Granulometry.fs
index a9a102a..db299dc 100644 (file)
@@ -10,7 +10,7 @@ open Utils
 
 // 'range': a minimum and maximum radius.
 // 'scale': <= 1.0, to speed up the process.
-let findRadius (img: Image<Gray, byte>)  (range: int * int) (scale: float) : int =
+let findRadius (img: Image<Gray, byte>) (range: int * int) (scale: float) : int =
     use scaledImg = if scale = 1.0 then img else img.Resize(scale, CvEnum.Inter.Area)
 
     let r1, r2 = range
@@ -24,15 +24,15 @@ let findRadius (img: Image<Gray, byte>)  (range: int * int) (scale: float) : int
         let se = CvInvoke.GetStructuringElement(CvEnum.ElementShape.Ellipse, Size(2 * r, 2 * r), Point(-1, -1))
         use closed = scaledImg.MorphologyEx(CvEnum.MorphOp.Close, se, Point(-1, -1), 1, CvEnum.BorderType.Replicate, MCvScalar(0.0))
 
-        let n = 1.0 - closed.GetSum().Intensity / intensityImg
+        let n = closed.GetSum().Intensity
 
         if not (Double.IsNaN previous_n)
         then
             patternSpectrum.[r - r1' - 1] <- abs (n - previous_n)
         previous_n <- n
 
-    let max = patternSpectrum |> Array.indexed |> Array.fold (fun (iMax, sMax) (i, s) -> if s > sMax then (i, s) else (iMax, sMax)) (0, Double.MinValue)
+    let max, _ = patternSpectrum |> Array.indexed |> Array.fold (fun (iMax, sMax) (i, s) -> if s > sMax then (i, s) else (iMax, sMax)) (0, Double.MinValue)
 
-    0
+    float (max + r1') / scale |> roundInt