2330227295a005c82a54f83d991d6a793c8ecc3c
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 () =
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
.Name with get
() = name and set
value = name <- value
40 member this
.Config = config
42 member this
.DateLastAnalysis with get
() = dateLastAnalysis and set
value = dateLastAnalysis <- value
48 and set
value = rbcs <- value
50 member this
.ImageParasitemia : int * int =
52 rbcs |> List.fold
(fun nbInfected rbc
-> if rbc
.infected
then nbInfected
+ 1 else nbInfected) 0
54 member this
.ImageNbManuallyChangedRBC (setAsInfected
: bool) : int * int =
56 rbcs |> List.fold
(fun nb rbc
-> if rbc
.setManually
&& rbc
.infected
= setAsInfected
then nb
+ 1 else nb) 0
58 member this
.ImageNbManuallyChangedRBCStr (setAsInfected
: bool) : string =
59 Utils.percentText
(this
.ImageNbManuallyChangedRBC setAsInfected
)
61 member this
.ImageManuallyChangedRBC (setAsInfected
: bool) : int seq =
64 where
(rbc
.setManually
&& rbc
.infected
= setAsInfected
)
68 member this
.ImageManuallyChangedRBCStr (setAsInfected
: bool) : string =
69 let listStr = Utils.listAsStr
<| this.ImageManuallyChangedRBC setAsInfected
75 member this.HealthyRBCBrightness with get
() = healthyRBCBrightness and set
value = healthyRBCBrightness <- value
76 member this.InfectedRBCBrightness with get
() = infectedRBCBrightness and set
value = infectedRBCBrightness <- value
78 member this.HealthyRBCColor : SolidColorBrush =
79 let mutable color = healthyRBColor * healthyRBCBrightness
81 SolidColorBrush (color)
83 member this.InfectedRBCColor : SolidColorBrush =
84 let mutable color = infectedRBColor * infectedRBCBrightness
86 SolidColorBrush (color)
88 member this.AverageRBCSize = averageRBCSize