X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemia%2FMainAnalysis.fs;h=5ee68865bac7a8f6f92e88081d25f198243aaa31;hb=999a48b8eb25c92e4403c9280fd4fe68f9bc4b7b;hp=9f91a6d3a143f229d4f0f38e2651980c6c0b9814;hpb=6b550c3faf4dea77738fa5c27cd9af277f45549c;p=master-thesis.git diff --git a/Parasitemia/Parasitemia/MainAnalysis.fs b/Parasitemia/Parasitemia/MainAnalysis.fs index 9f91a6d..5ee6886 100644 --- a/Parasitemia/Parasitemia/MainAnalysis.fs +++ b/Parasitemia/Parasitemia/MainAnalysis.fs @@ -3,6 +3,8 @@ open System open System.Drawing +open FSharp.Collections.ParallelSeq + open Emgu.CV open Emgu.CV.Structure @@ -19,9 +21,13 @@ let doAnalysis (img: Image) (name: string) (config: Config) : Cell li logTime "areaOpen 1" (fun () -> ImgTools.areaOpenF filteredGreen config.Parameters.initialAreaOpen) - config.RBCRadius <- logTime "Granulometry" (fun() -> Granulometry.findRadius (filteredGreen.Convert()) (10, 100) 0.3 |> float32) + let r1 = logTime "Granulometry (morpho)" (fun() -> Granulometry.findRadiusByClosing (filteredGreen.Convert()) (10, 80) 0.5 |> float32) + // let r2 = logTime "Granulometry (area)" (fun() -> Granulometry.findRadiusByAreaClosing filteredGreen (10, 80) |> float32) + // log (sprintf "r1: %A, r2: %A" r1 r2) + config.RBCRadius <- r1 let secondAreaOpen = int <| config.RBCArea / 3.f + if secondAreaOpen > config.Parameters.initialAreaOpen then logTime "areaOpen 2" (fun () -> ImgTools.areaOpenF filteredGreen secondAreaOpen) @@ -87,3 +93,13 @@ let doAnalysis (img: Image) (name: string) (config: Config) : Cell li | _ -> () cells + + +let doMultipleAnalysis (imgs: (string * Image) list) (config : Config) : (string * Cell list) list = + let nbConcurrentTaskLimit = 4 + let n = Environment.ProcessorCount + + imgs + |> PSeq.map (fun (id, img) -> id, doAnalysis img id (config.Copy())) + |> PSeq.withDegreeOfParallelism (if n > nbConcurrentTaskLimit then nbConcurrentTaskLimit else n) + |> PSeq.toList \ No newline at end of file