1
namespace ParasitemiaUI
5 open System.Windows.Media
12 type SourceImage (num
: int, name
: string, config
: ParasitemiaCore.Config.Config, dateLastAnalysis
: DateTime, img
: Image<Bgr, byte
>, rbcs
: RBC list
) =
14 let mutable name = name
15 let mutable config = config
16 let mutable dateLastAnalysis = dateLastAnalysis // UTC.
18 let mutable rbcs = rbcs
19 let mutable healthyRBCBrightness = 1.f
20 let mutable infectedRBCBrightness = 1.f
22 let mutable averageRBCSize = 1.
24 let healthyRBColor = Color.FromRgb (255uy, 255uy, 0uy) // Yellow-green.
25 let infectedRBColor = Color.FromRgb (255uy, 0uy, 40uy) // Red with a bit of blue.
27 let updateAverageRBCSize () =
28 if List.isEmpty
rbcs |> not
then
31 |> List.collect
(fun rbc
-> [ rbc
.size
.Width; rbc
.size
.Height ])
35 updateAverageRBCSize ()
37 member this
.Num with get
() = num and set
value = num <- value
39 member this
.RomanNum = Utils.toRomanNumber this
.Num
41 member this
.Name with get
() = name and set
value = name <- value
43 member this
.Config = config
45 member this
.DateLastAnalysis with get
() = dateLastAnalysis and set
value = dateLastAnalysis <- value
53 updateAverageRBCSize ()
55 member this
.ImageParasitemia : int * int =
57 rbcs |> List.fold
(fun nbInfected rbc
-> if rbc
.infected
then nbInfected
+ 1 else nbInfected) 0
59 member this
.ImageNbManuallyChangedRBC (setAsInfected
: bool) : int * int =
61 rbcs |> List.fold
(fun nb rbc
-> if rbc
.setManually
&& rbc
.infected
= setAsInfected
then nb
+ 1 else nb) 0
63 member this
.ImageNbManuallyChangedRBCStr (setAsInfected
: bool) : string =
64 Utils.percentText
(this
.ImageNbManuallyChangedRBC setAsInfected
)
66 member this
.ImageManuallyChangedRBC (setAsInfected
: bool) : int seq =
69 where
(rbc
.setManually
&& rbc
.infected
= setAsInfected
)
73 member this
.ImageManuallyChangedRBCStr (setAsInfected
: bool) : string =
74 let listStr = Utils.listAsStr
<| this.ImageManuallyChangedRBC setAsInfected
80 member this.HealthyRBCBrightness with get
() = healthyRBCBrightness and set
value = healthyRBCBrightness <- value
81 member this.InfectedRBCBrightness with get
() = infectedRBCBrightness and set
value = infectedRBCBrightness <- value
83 member this.HealthyRBCColor : SolidColorBrush =
84 let mutable color = healthyRBColor * healthyRBCBrightness
86 SolidColorBrush (color)
88 member this.InfectedRBCColor : SolidColorBrush =
89 let mutable color = infectedRBColor * infectedRBCBrightness
91 SolidColorBrush (color)
93 member this.AverageRBCSize = averageRBCSize