Update coding style.
[master-thesis.git] / Parasitemia / ParasitemiaUI / Types.fs
1 module ParasitemiaUI.Types
2
3 open System
4 open System.Windows
5 open System.Windows.Media
6
7 open Emgu.CV
8 open Emgu.CV.Structure
9
10 open Newtonsoft.Json
11
12 open ParasitemiaCore.UnitsOfMeasure
13
14 let healthyRBColor = Color.FromRgb (255uy, 255uy, 0uy) // Yellow-green.
15 let infectedRBColor = Color.FromRgb (255uy, 0uy, 40uy) // Red with a bit of blue.
16
17 type RBC =
18 {
19 num : int
20
21 [<JsonIgnore>]
22 mutable infected : bool
23
24 [<JsonIgnore>]
25 mutable setManually : bool
26
27 center : Point
28 size : Size
29 infectedArea : int
30 }
31
32 type SourceImage =
33 {
34 mutable num : int
35 mutable name : string
36
37 mutable config : ParasitemiaCore.Config.Config
38 mutable dateLastAnalysis : DateTime // UTC.
39 img : Image<Bgr, byte>
40 mutable rbcs : RBC list
41
42 mutable healthyRBCBrightness : float32
43 mutable infectedRBCBrightness : float32
44 }
45 with
46 member this.HealthyRBCColor : SolidColorBrush =
47 let mutable color = healthyRBColor * this.healthyRBCBrightness
48 color.A <- 255uy
49 SolidColorBrush (color)
50
51 member this.InfectedRBCColor : SolidColorBrush =
52 let mutable color = infectedRBColor * this.infectedRBCBrightness
53 color.A <- 255uy
54 SolidColorBrush (color)
55
56 type PredefinedPPI =
57 {
58 ppi : int<ppi>
59 label : string
60 }
61 with
62 override this.ToString () =
63 sprintf "%s: %d" this.label this.ppi
64
65 type SensorSize =
66 {
67 w : float<mm>
68 h : float<mm>
69 label : string
70 }
71 with
72 override this.ToString () =
73 sprintf "%g mm × %g mm%s" this.w this.h (if this.label = "" then "" else " (" + this.label + ")")
74
75 let defaultPredefinedPPI =
76 [
77 { ppi = 230000<ppi>; label = "50×" }
78 { ppi = 460000<ppi>; label = "100×" }
79 ]
80
81 let defaultSensorSizes =
82 [
83 { w = 3.2<mm>; h = 2.4<mm>; label = "1/4″" }
84 { w = 4.8<mm>; h = 3.6<mm>; label = "1/3″" }
85 { w = 5.76<mm>; h = 4.29<mm>; label = "1/2.5″" }
86 { w = 6.4<mm>; h = 4.8<mm>; label = "1/2″" }
87 { w = 7.18<mm>; h = 5.32<mm>; label = "1/1.8″" }
88 { w = 7.6<mm>; h = 5.7<mm>; label = "1/1.7″" }
89 { w = 8.8<mm>; h = 6.6<mm>; label = "2/3″" }
90 { w = 13.2<mm>; h = 8.8<mm>; label = "1″" }
91 ]
92
93