+
+
+// ID * cell radius * cell list.
+let doMultipleAnalysis (imgs: (string * Image<Bgr, byte>) list) (config : Config) (reportProgress: (int -> unit) option) : (string * float * Cell list) list =
+ let inline report (percent: int) =
+ match reportProgress with
+ | Some f -> f percent
+ | _ -> ()
+
+ let monitor = Object()
+ let mutable total = 0
+ let nbImgs = List.length imgs
+ let reportProgressImg =
+ (fun progress ->
+ lock monitor (fun () -> total <- total + progress)
+ report (total / nbImgs))
+
+ let nbConcurrentTaskLimit = 4
+ let n = Environment.ProcessorCount
+
+ imgs
+ |> PSeq.map (fun (id, img) ->
+ let localConfig = config.Copy()
+ let cells = doAnalysis img id localConfig (Some reportProgressImg)
+ id, float localConfig.RBCRadius, cells)
+ |> PSeq.withDegreeOfParallelism (if n > nbConcurrentTaskLimit then nbConcurrentTaskLimit else n)
+ |> PSeq.toList