From: Greg Burri Date: Sun, 3 Jan 2016 21:21:55 +0000 (+0100) Subject: Cleaning. X-Git-Tag: 1.0.11~66 X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=962440dfe579569ba7e3ebba6f878cb575d1fc02;p=master-thesis.git Cleaning. --- diff --git a/Parasitemia/Parasitemia/Config.fs b/Parasitemia/Parasitemia/Config.fs index 5740e8b..7f841c4 100644 --- a/Parasitemia/Parasitemia/Config.fs +++ b/Parasitemia/Parasitemia/Config.fs @@ -9,6 +9,8 @@ type Debug = type Parameters = { scale: float + initialAreaOpen: int + minRbcRadius: float maxRbcRadius: float diff --git a/Parasitemia/Parasitemia/MainAnalysis.fs b/Parasitemia/Parasitemia/MainAnalysis.fs index a240878..167e618 100644 --- a/Parasitemia/Parasitemia/MainAnalysis.fs +++ b/Parasitemia/Parasitemia/MainAnalysis.fs @@ -17,34 +17,22 @@ let doAnalysis (img: Image) (name: string) (config: Config) : Cell li use scaledImg = if config.Parameters.scale = 1.0 then img else img.Resize(config.Parameters.scale, CvEnum.Inter.Area) use green = scaledImg.Item(1) - let greenFloat = green.Convert() - let filteredGreen = gaussianFilter greenFloat config.Parameters.preFilterSigma - (*let maximaImg = filteredGreen.Copy() - let maxima = logTime "maxima" (fun () -> ImgTools.findMaxima maximaImg) - for m in maxima do - ImgTools.drawPoints maximaImg m 255uy - - let greenOpen1 = filteredGreen.Copy() - logTime "areaOpen1" (fun () -> ImgTools.areaOpen greenOpen1 2000)*) + logTime "areaOpen 1" (fun () -> ImgTools.areaOpenF filteredGreen config.Parameters.initialAreaOpen) - let initialAreaOpen = 2000 - logTime "areaOpen 1" (fun () -> ImgTools.areaOpenF filteredGreen initialAreaOpen) - - config.RBCRadius <- Granulometry.findRadius filteredGreen (10, 100) 0.5 |> float + config.RBCRadius <- logTime "Granulometry" (fun() -> Granulometry.findRadius (filteredGreen.Convert()) (10, 100) 0.5 |> float) let secondAreaOpen = int <| config.RBCArea / 3. - if secondAreaOpen > initialAreaOpen + if secondAreaOpen > config.Parameters.initialAreaOpen then logTime "areaOpen 2" (fun () -> ImgTools.areaOpenF filteredGreen secondAreaOpen) let parasites, filteredGreenWhitoutInfection, filteredGreenWhitoutStain = ParasitesMarker.find filteredGreen config //let parasites, filteredGreenWhitoutInfection, filteredGreenWhitoutStain = ParasitesMarker.findMa greenFloat filteredGreenFloat config - let edges, xGradient, yGradient = ImgTools.findEdges filteredGreenWhitoutStain - + let edges, xGradient, yGradient = logTime "Finding edges" (fun () -> ImgTools.findEdges filteredGreenWhitoutStain) logTime "Removing small connected components from thinning" (fun () -> removeArea edges 12) let allEllipses, ellipses = logTime "Finding ellipses" (fun () -> diff --git a/Parasitemia/Parasitemia/ParasitesMarker.fs b/Parasitemia/Parasitemia/ParasitesMarker.fs index 9e46c23..71c15a9 100644 --- a/Parasitemia/Parasitemia/ParasitesMarker.fs +++ b/Parasitemia/Parasitemia/ParasitesMarker.fs @@ -61,11 +61,11 @@ let find (filteredGreen: Image) (config: Config.Config) : Result // We use the filtered image to find the dark stain. // With K-Means. - let kmeansResults = logTime "Finding fg/bg (k-means)" (fun () -> KMeans.kmeans (filteredGreenWithoutInfection.Convert()) 1.0) + let kmeansResults = logTime "Finding fg/bg (k-means)" (fun () -> KMeans.kmeans (filteredGreenWithoutInfection) 1.0) let { KMeans.mean_bg = value_bg; KMeans.mean_fg = value_fg; KMeans.d_fg = d_fg } = kmeansResults // With K-Medians. - (* let kmediansResults = logTime "Finding fg/bg (k-medians)" (fun () -> KMedians.kmedians (filteredGreenWithoutInfection.Convert()) 1.0) // FIXME: avoid converting this again in MainAnalysis + (* let kmediansResults = logTime "Finding fg/bg (k-medians)" (fun () -> KMedians.kmedians (filteredGreenWithoutInfection) 1.0) // FIXME: avoid converting this again in MainAnalysis let { KMedians.median_bg = value_bg; KMedians.median_fg = value_fg; KMedians.d_fg = d_fg } = kmediansResults *) let darkStain = d_fg.Cmp(value_bg * config.Parameters.darkStainLevel, CvEnum.CmpType.GreaterThan) diff --git a/Parasitemia/Parasitemia/Program.fs b/Parasitemia/Parasitemia/Program.fs index dffc8fd..94d2999 100644 --- a/Parasitemia/Parasitemia/Program.fs +++ b/Parasitemia/Parasitemia/Program.fs @@ -61,6 +61,8 @@ let main args = Config( { scale = 1. + initialAreaOpen = 2000 + minRbcRadius = -0.32 maxRbcRadius = 0.32