X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FGranulometry.fs;h=0ef862b05d1a020574cff7ac666ca53e6dc655be;hp=a9a102a80b2fd6bfbdadc591cc43a69c6fec05c8;hb=044b0ae69df3ac565432545b2fa934589016f9bd;hpb=b070295cf67b2025164a34b6594e84f0d771cdc9 diff --git a/Parasitemia/Parasitemia/Granulometry.fs b/Parasitemia/Parasitemia/Granulometry.fs index a9a102a..0ef862b 100644 --- a/Parasitemia/Parasitemia/Granulometry.fs +++ b/Parasitemia/Parasitemia/Granulometry.fs @@ -10,8 +10,8 @@ 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 = - use scaledImg = if scale = 1.0 then img else img.Resize(scale, CvEnum.Inter.Area) +let findRadius (img: Image) (range: int * int) (scale: float) : int = + use scaledImg = if scale = 1. then img else img.Resize(scale, CvEnum.Inter.Area) let r1, r2 = range let r1', r2' = roundInt (float r1 * scale), roundInt (float r2 * scale) @@ -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