X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FGranulometry.fs;h=ea5ef67e352720cf4b21434015c4cc434b667787;hb=a498bc4223a22cd38b91b3348912301e15c077ae;hp=bbb6d66fd6e88346060bf54638f7b9d458e50c00;hpb=b87b35b922551f122228df1fd9c530bbb807935a;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaCore/Granulometry.fs b/Parasitemia/ParasitemiaCore/Granulometry.fs index bbb6d66..ea5ef67 100644 --- a/Parasitemia/ParasitemiaCore/Granulometry.fs +++ b/Parasitemia/ParasitemiaCore/Granulometry.fs @@ -1,7 +1,6 @@ module ParasitemiaCore.Granulometry open System -open System.IO open System.Drawing open Emgu.CV @@ -15,8 +14,9 @@ open Utils /// /// Minimum radius * maximum radius /// le 1.0, to speed up the process. +/// let findRadiusByClosing (img : Image) (range : int * int) (scale : float) (useOctagon : bool) : int = - use scaledImg = if scale = 1. then img else img.Resize(scale, CvEnum.Inter.Area) + 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) @@ -27,7 +27,7 @@ let findRadiusByClosing (img : Image) (range : int * int) (scale // 's' must be odd. let octagon (s : int) : Matrix = if s % 2 = 0 then failwith "s must be odd" - let m = new Matrix(Array2D.create s s 1uy) + let m = new Matrix (Array2D.create s s 1uy) let r = (float s) / (Math.Sqrt 2. + 2.) |> roundInt for i = 0 to r - 1 do for j = 0 to r - 1 do @@ -44,9 +44,9 @@ let findRadiusByClosing (img : Image) (range : int * int) (scale if useOctagon then (octagon (2 * r - 1)).Mat // It doesn't speed up the process. else - CvInvoke.GetStructuringElement(CvEnum.ElementShape.Ellipse, Size(2 * r, 2 * r), Point(-1, -1)) + 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)) + use closed = scaledImg.MorphologyEx (CvEnum.MorphOp.Close, se, Point (-1, -1), 1, CvEnum.BorderType.Replicate, MCvScalar (0.0)) let n = closed.GetSum().Intensity @@ -67,14 +67,17 @@ let findRadiusByAreaClosing (img : Image) (radiusRange : int * in if r1 > r2 then failwithf "'radiusRange' invalid : %O" radiusRange - use imgCopy = img.Copy() + use imgCopy = img.Copy () let mutable maxDiff = 0.f let mutable max_r = r1 - Morpho.areaCloseFWithFun imgCopy [ for r in r1 .. r2 -> Math.PI * float r ** 2. |> roundInt, r ] (fun r diff -> - if r <> r1 && diff > maxDiff then - maxDiff <- diff - max_r <- r - 1) + Morpho.areaCloseFWithFun imgCopy [ for r in r1 .. r2 -> Math.PI * float r ** 2. |> roundInt, r ] ( + fun r diff -> + if r <> r1 && diff > maxDiff then + maxDiff <- diff + max_r <- r - 1 + ) + max_r