X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaUI%2FState.fs;h=69662d502fb71ab9124cdc7ce8eb68c60f971469;hb=ec96e4c38dd6beaf22b4e2a2ebb87248fea6f209;hp=e15dc9b7a06b4325cbc9170e4ccf516628be2244;hpb=db49e167a602ef1df02a8b5f7de334355a4917dd;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaUI/State.fs b/Parasitemia/ParasitemiaUI/State.fs index e15dc9b..69662d5 100644 --- a/Parasitemia/ParasitemiaUI/State.fs +++ b/Parasitemia/ParasitemiaUI/State.fs @@ -136,26 +136,27 @@ 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) sourceImage.rbcs <- cells |> List.filter (fun cell -> match cell.cellClass with ParasitemiaCore.Types.HealthyRBC | ParasitemiaCore.Types.InfectedRBC -> true | _ -> false ) - |> List.sortByDescending (fun cell -> cell.infectedArea, (w - cell.center.X) + (h - cell.center.Y)) + |> List.sortByDescending (fun cell -> cell.nucleusArea, (w - cell.center.X) + (h - cell.center.Y)) |> 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 setManually = setManually center = center size = Size(float cell.elements.Width, float cell.elements.Height) - infectedArea = cell.infectedArea }) + infectedArea = cell.nucleusArea }) alteredSinceLastSave <- true