1
namespace ParasitemiaUI
4 open System.Windows.Media
11 type SourceImage (num
: int, name
: string, config
: ParasitemiaCore.Config.Config, dateLastAnalysis
: DateTime, img
: Image<Bgr, byte
>, rbcs
: RBC list
) =
13 let mutable name = name
14 let mutable config = config
15 let mutable dateLastAnalysis = dateLastAnalysis // UTC.
17 let mutable rbcs = rbcs
18 let mutable healthyRBCBrightness = 1.f
19 let mutable infectedRBCBrightness = 1.f
21 let mutable averageRBCSize = 1.
23 let healthyRBColor = Color.FromRgb (255uy, 255uy, 0uy) // Yellow-green.
24 let infectedRBColor = Color.FromRgb (255uy, 0uy, 40uy) // Red with a bit of blue.
26 let updateAverageRBCSize () =
27 if List.isEmpty
rbcs |> not
then
30 |> List.collect
(fun rbc
-> [ rbc
.size
.Width; rbc
.size
.Height ])
34 updateAverageRBCSize ()
36 member this
.Num with get
() = num and set
value = num <- value
38 member this
.RomanNum = Utils.toRomanNumber this
.Num
40 member this
.Name with get
() = name and set
value = name <- value
42 member this
.Config = config
44 member this
.DateLastAnalysis with get
() = dateLastAnalysis and set
value = dateLastAnalysis <- value
52 updateAverageRBCSize ()
54 member this
.ImageParasitemia : int * int =
56 rbcs |> List.fold
(fun nbInfected rbc
-> if rbc
.infected
then nbInfected
+ 1 else nbInfected) 0
58 member this
.ImageNbManuallyChangedRBC (setAsInfected
: bool) : int * int =
60 rbcs |> List.fold
(fun nb rbc
-> if rbc
.setManually
&& rbc
.infected
= setAsInfected
then nb
+ 1 else nb) 0
62 member this
.ImageNbManuallyChangedRBCStr (setAsInfected
: bool) : string =
63 Utils.percentText
(this
.ImageNbManuallyChangedRBC setAsInfected
)
65 member this
.ImageManuallyChangedRBC (setAsInfected
: bool) : int seq =
68 where
(rbc
.setManually
&& rbc
.infected
= setAsInfected
)
72 member this
.ImageManuallyChangedRBCStr (setAsInfected
: bool) : string =
73 let listStr = Utils.listAsStr
<| this.ImageManuallyChangedRBC setAsInfected
79 member this.HealthyRBCBrightness with get
() = healthyRBCBrightness and set
value = healthyRBCBrightness <- value
80 member this.InfectedRBCBrightness with get
() = infectedRBCBrightness and set
value = infectedRBCBrightness <- value
82 member this.HealthyRBCColor : SolidColorBrush =
83 let mutable color = healthyRBColor * healthyRBCBrightness
85 SolidColorBrush (color)
87 member this.InfectedRBCColor : SolidColorBrush =
88 let mutable color = infectedRBColor * infectedRBCBrightness
90 SolidColorBrush (color)
92 member this.AverageRBCSize = averageRBCSize