* Add logos CHUV and HES-SO.
[master-thesis.git] / Parasitemia / ParasitemiaCore / MainAnalysis.fs
index be72a2b..7b8b066 100644 (file)
@@ -16,8 +16,20 @@ open ImgTools
 open Config
 open Types
 
+/// <summary>
+/// Analyze the given image and detect reb blood cell (RBC) in it.
+/// </summary>
+/// <param name="img">The image</param>
+/// <param name="name">The name, used during logging</param>
+/// <param name="config">The configuration, must not be shared with another analysis</param>
+/// <param name="reportProgress">An optional function to report progress and/or cancel the process.
+///     The first call returning 'false' will cancel the analysis.
+///     The 'int' parameter correspond to the progression from 0 to 100</param>
+/// <returns>A list of detected cells or nothing if the process has been cancelled</returns>
 let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportProgress: (int -> bool) option) : Cell list option =
+
     // To report the progress of this function from 0 to 100.
+    // Return 'None' if the process must be aborted.
     let reportWithVal (percent: int) (value: 'a) : 'a option =
         match reportProgress with
         | Some f ->
@@ -29,7 +41,7 @@ let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
     let report (percent: int) : unit option =
         reportWithVal percent ()
 
-    let inline buildLogWithName (text:  string) = sprintf "(%s) %s" name text
+    let inline buildLogWithName (text: string) = sprintf "(%s) %s" name text
     let logWithName mess = Log.User(buildLogWithName mess)
     let inline logTimeWithName (text: string) (f: unit -> 'a option) : 'a option = Log.LogWithTime((buildLogWithName text), Severity.USER, f)
 
@@ -47,8 +59,6 @@ let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
         let initialAreaOpening = int <| config.RBCRadiusByResolution.Area * config.Parameters.ratioAreaPaleCenter * 1.2f // We do an area opening a little larger to avoid to do a second one in the case the radius found is near the initial one.
         do! logTimeWithName "First area opening" (fun () -> ImgTools.areaOpenF filteredGreen initialAreaOpening; report 10)
 
-        //do! report 10
-
         let range =
             let delta = config.Parameters.granulometryRange * config.RBCRadiusByResolution.Pixel
             int <| config.RBCRadiusByResolution.Pixel - delta, int <| config.RBCRadiusByResolution.Pixel + delta
@@ -138,8 +148,11 @@ let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
 /// <summary>
 /// Do multiple analyses on the same time. The number of concurrent process depends if the number of the core.
 /// </summary>
-/// <param name="imgs"></param>
-/// <param name="reportProgress">An optional function to report progress. The process is aborted if the returned value is false</param>
+/// <param name="imgs">The images: (name * configuration * image)</param>
+/// <param name="reportProgress">An optional function to report progress and/or cancel the process.
+///     The first call returning 'false' will cancel the analysis.
+///     The 'int' parameter correspond to the progression from 0 to 100</param>
+/// <returns>'None' if the process has been cancelled or the list of result as (name * cells), 'name' corresponds to the given name<returns>
 let doMultipleAnalysis (imgs: (string * Config * Image<Bgr, byte>) list) (reportProgress: (int -> bool) option) : (string * Cell list) list option =
     let report (percent: int) : bool =
         match reportProgress with