- let infectedPixels = List<Point>()
- let cytoplasmPixels = List<Point>()
-
- //let mutable stainPixels = 0
- let mutable darkStainPixels = 0
- let mutable nbElement = 0
-
- let elements = new Matrix<byte>(maxY - minY + 1, maxX - minX + 1)
- for y in minY .. maxY do
- for x in minX .. maxX do
- let p = PointF(float32 x, float32 y)
- if pixelOwnedByE p e (neighbors |> List.choose (fun (otherE, p1, p2) -> if otherE.Removed then None else Some (otherE :> Ellipse, Utils.lineFromTwoPoints p1 p2)))
- then
- elements.[y-minY, x-minX] <- 1uy
- nbElement <- nbElement + 1
-
- let infected = infection.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
- then
- infectedPixels.Add(Point(x, y))
-
- if stain
- then
- cytoplasmPixels.Add(Point(x, y))
-
- if darkStain
- then
- darkStainPixels <- darkStainPixels + 1
-
- let mutable cytoplasmArea = 0
- if infectedPixels.Count > 0
- then
- for cytoplasmPixel in cytoplasmPixels do
- if infectedPixels.Exists(fun p -> pown (p.X - cytoplasmPixel.X) 2 + pown (p.Y - cytoplasmPixel.Y) 2 <= perimeterParasiteSquared)
- then
- cytoplasmArea <- cytoplasmArea + 1
-
-
- let cellClass =
- if float darkStainPixels > config.Parameters.maxDarkStainRatio * (float nbElement)
- //|| float stainPixels > config.Parameters.maxStainRatio * (float nbElement)
- then
- Peculiar
-
- elif infectedPixels.Count > 0 && cytoplasmArea >= minimumParasiteArea
- then
- let infectionToRemove = ImgTools.connectedComponents parasites.cytoplasm infectedPixels
- for p in infectionToRemove do
- infection.Data.[p.Y, p.X, 0] <- 0uy
- InfectedRBC