Cleaning syntax.
[master-thesis.git] / Parasitemia / ParasitemiaCore / ParasitesMarker.fs
index 2b70682..263e35e 100644 (file)
@@ -12,12 +12,14 @@ open Otsu
 open Morpho
 open ImgTools
 
-type Result = {
-    darkStain: Image<Gray, byte> // Colored pixel, it's independent of the size of the areas. It corresponds to white cells, schizontes, gametocytes, throphozoites.
-    nucleus: Image<Gray, byte> // Parasite nucleus. It may contain some debris. It shouldn't contain thrombocytes or larger elements.
-    parasite: Image<Gray, byte> } // The whole parasites.
+type Result =
+    {
+        darkStain : Image<Gray, byte> // Colored pixel, it's independent of the size of the areas. It corresponds to white cells, schizontes, gametocytes, throphozoites.
+        nucleus : Image<Gray, byte> // Parasite nucleus. It may contain some debris. It shouldn't contain thrombocytes or larger elements.
+        parasite : Image<Gray, byte> // The whole parasites.
+    }
 
-let find (img: Image<Gray, float32>) (config: Config.Config) : Result * Image<Gray, float32> * Image<Gray, float32> =
+let find (img : Image<Gray, float32>) (config : Config.Config) : Result * Image<Gray, float32> * Image<Gray, float32> =
 
     let imgWithoutNucleus = img.Copy()
     areaCloseF imgWithoutNucleus (roundInt config.RBCRadius.NucleusArea)
@@ -29,7 +31,7 @@ let find (img: Image<Gray, float32>) (config: Config.Config) : Result * Image<Gr
             otsu hist
         imgWithoutNucleus.Cmp(float mean_fg - config.Parameters.darkStainLevel * float (mean_bg - mean_fg), CvEnum.CmpType.LessThan)
 
-    let marker (img: Image<Gray, float32>) (closed: Image<Gray, float32>) (level: float) : Image<Gray, byte> =
+    let marker (img : Image<Gray, float32>) (closed : Image<Gray, float32>) (level : float) : Image<Gray, byte> =
         let diff = img.Copy()
         diff._Mul(level)
         CvInvoke.Subtract(closed, diff, diff)
@@ -45,8 +47,7 @@ let find (img: Image<Gray, float32>) (config: Config.Config) : Result * Image<Gr
         let size = roundInt config.RBCRadius.CytoplasmSize
         if size % 2 = 0 then size + 1 else size
     use kernel =
-        if kernelSize <= 3
-        then
+        if kernelSize <= 3 then
             CvInvoke.GetStructuringElement(CvEnum.ElementShape.Rectangle, Size(3, 3), Point(-1, -1))
         else
             CvInvoke.GetStructuringElement(CvEnum.ElementShape.Ellipse, Size(kernelSize, kernelSize), Point(-1, -1))
@@ -54,9 +55,11 @@ let find (img: Image<Gray, float32>) (config: Config.Config) : Result * Image<Gr
     CvInvoke.MorphologyEx(img, imgWithoutParasite, CvEnum.MorphOp.Close, kernel, Point(-1, -1), 1, CvEnum.BorderType.Replicate, MCvScalar())
     let parasiteMarker = marker img imgWithoutParasite (1. / config.Parameters.cytoplasmSensitivity)
 
-    { darkStain = darkStain
-      nucleus = nucleusMarker
-      parasite = parasiteMarker },
+    {
+        darkStain = darkStain
+        nucleus = nucleusMarker
+        parasite = parasiteMarker
+    },
     imgWithoutParasite,
     imgWithoutNucleus