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<Gray, float32>()
-
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<Gray, byte>()) (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 () ->
// 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<Gray, float32>()) 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<Gray, float32>()) 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)