Remove the parasite detection function from Ma.
[master-thesis.git] / Parasitemia / ParasitemiaCore / Classifier.fs
index 96532f8..2b6f3be 100644 (file)
@@ -24,7 +24,7 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
     then
         []
     else
-        let infection = parasites.infection.Copy() // To avoid to modify the parameter.
+        let infection = parasites.nucleus.Copy() // To avoid to modify the parameter.
 
         // This is the minimum window size to check if other ellipses touch 'e'.
         let searchRegion (e: Ellipse) = { KdTree.minX = e.Cx - (e.A + config.RBCRadius.Max)
@@ -159,7 +159,7 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
                 let minX, minY, maxX, maxY = ellipseWindow e
 
                 let infectedPixels = List<Point>()
-                let stainPixels = List<Point>()
+                let cytoplasmPixels = List<Point>()
 
                 //let mutable stainPixels = 0
                 let mutable darkStainPixels = 0
@@ -175,7 +175,7 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
                             nbElement <- nbElement + 1
 
                             let infected = infection.Data.[y, x, 0] > 0uy
-                            let stain = parasites.stain.Data.[y, x, 0] > 0uy
+                            let stain = parasites.cytoplasm.Data.[y, x, 0] > 0uy
                             let darkStain = parasites.darkStain.Data.[y, x, 0] > 0uy
 
                             if infected
@@ -184,19 +184,19 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
 
                             if stain
                             then
-                                stainPixels.Add(Point(x, y))
+                                cytoplasmPixels.Add(Point(x, y))
 
                             if darkStain
                             then
                                 darkStainPixels <- darkStainPixels + 1
 
-                let mutable stainArea = 0
+                let mutable cytoplasmArea = 0
                 if infectedPixels.Count > 0
                 then
-                    for stainPixel in stainPixels do
-                        if infectedPixels.Exists(fun p -> pown (p.X - stainPixel.X) 2 + pown (p.Y - stainPixel.Y) 2 <= perimeterParasiteSquared)
+                    for cytoplasmPixel in cytoplasmPixels do
+                        if infectedPixels.Exists(fun p -> pown (p.X - cytoplasmPixel.X) 2 + pown (p.Y - cytoplasmPixel.Y) 2 <= perimeterParasiteSquared)
                         then
-                            stainArea <- stainArea + 1
+                            cytoplasmArea <- cytoplasmArea + 1
 
 
                 let cellClass =
@@ -205,9 +205,9 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
                     then
                         Peculiar
 
-                    elif infectedPixels.Count > 0 && stainArea >= minimumParasiteArea
+                    elif infectedPixels.Count > 0 && cytoplasmArea >= minimumParasiteArea
                     then
-                        let infectionToRemove = ImgTools.connectedComponents parasites.stain infectedPixels
+                        let infectionToRemove = ImgTools.connectedComponents parasites.cytoplasm infectedPixels
                         for p in infectionToRemove do
                             infection.Data.[p.Y, p.X, 0] <- 0uy
                         InfectedRBC
@@ -217,6 +217,6 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img:
 
                 Some { cellClass = cellClass
                        center = Point(roundInt e.Cx, roundInt e.Cy)
-                       infectedArea = if cellClass = InfectedRBC then infectedPixels.Count else 0
-                       stainArea = stainArea
+                       nucleusArea = if cellClass = InfectedRBC then infectedPixels.Count else 0
+                       parasiteArea = cytoplasmArea
                        elements = elements })