X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FGranulometry.fs;h=b18f53c2d59050d55bd9a59398ea286cb1dc9e69;hp=a9a102a80b2fd6bfbdadc591cc43a69c6fec05c8;hb=d0c85068bb98a7999ed994f02669befa70edd5f9;hpb=b070295cf67b2025164a34b6594e84f0d771cdc9 diff --git a/Parasitemia/Parasitemia/Granulometry.fs b/Parasitemia/Parasitemia/Granulometry.fs index a9a102a..b18f53c 100644 --- a/Parasitemia/Parasitemia/Granulometry.fs +++ b/Parasitemia/Parasitemia/Granulometry.fs @@ -10,7 +10,7 @@ open Utils // 'range': a minimum and maximum radius. // 'scale': <= 1.0, to speed up the process. -let findRadius (img: Image) (range: int * int) (scale: float) : int = +let findRadius (img: Image) (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) (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