Change the way the dark stain is marked.
[master-thesis.git] / Parasitemia / ParasitemiaUI / State.fs
index 5b6a91c..69662d5 100644 (file)
@@ -136,7 +136,7 @@ type State (defaultConfig: ParasitemiaCore.Config.Config) =
         // To match with previously manually altered RBC.
         let manuallyAlteredPreviousRBCS = sourceImage.rbcs |> List.filter (fun rbc -> rbc.setManually)
         let tolerance = (float sourceImage.config.RBCRadius.Pixel) * 0.5 // +/-.
-        let getPreviousRBC (center: Point) : RBC option =
+        let getPreviousManuallyAlteredRBC (center: Point) : RBC option =
             manuallyAlteredPreviousRBCS |> List.tryFind (fun rbc -> rbc.center.X > center.X - tolerance && rbc.center.X < center.X + tolerance &&
                                                                     rbc.center.Y > center.Y - tolerance && rbc.center.Y < center.Y + tolerance)
 
@@ -146,9 +146,10 @@ type State (defaultConfig: ParasitemiaCore.Config.Config) =
             |> List.mapi (fun i cell ->
                 let center = Point(float cell.center.X, float cell.center.Y)
                 let infected, setManually =
-                    match getPreviousRBC center with
-                    | Some rbc -> rbc.infected, true
-                    | _ -> cell.cellClass = ParasitemiaCore.Types.InfectedRBC, false
+                    let infected = cell.cellClass = ParasitemiaCore.Types.InfectedRBC
+                    match getPreviousManuallyAlteredRBC center with
+                    | Some rbc when rbc.infected <> infected -> rbc.infected, true // If it has been previously manually changed and now match the result, the manually flag is removed.
+                    | _ -> infected, false
 
                 { num = i + 1
                   infected = infected