First commit of the f# source code.
[master-thesis.git] / Parasitemia / Parasitemia / Program.fs
1 module Parasitemia.Main
2
3 open System.IO
4 open System.Windows
5 open System.Windows.Media
6 open System.Windows.Markup
7 open System.Windows.Shapes
8 open System.Windows.Controls
9 open System.Drawing
10 open System.Diagnostics
11
12 open Emgu.CV
13 open Emgu.CV.Structure
14 open Emgu.CV.WPF
15
16 open Config
17
18 let display (window : Views.MainWindow) (img : IImage) =
19 let imgControl = window.Root.FindName("img") :?> Controls.Image
20 imgControl.Source <- BitmapSourceConvert.ToBitmapSource(img)
21
22 let log (window : Views.MainWindow) (mess : string) =
23 let txtLog = window.Root.FindName("txtLog") :?> Controls.TextBlock
24 txtLog.Text <- txtLog.Text + mess + "\n"
25
26 [<System.STAThreadAttribute>]
27 do
28 Utils.dprintfn "OpenCV test"
29
30 let app = new Application()
31 let mainWindow = Views.MainWindow()
32
33 Utils.log <- (fun m -> log mainWindow m)
34
35 let config = {
36 doGSigma1 = 1.5
37 doGSigma2 = 20.0
38 doGLowFreqPercentageReduction = 0.9
39 scale = 1.0
40 }
41
42 //use img = new Image<Rgb, byte>("../../../../src/Tests_hough/images/1508133543-7-4-120-0001.png")
43 //use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/rbc_single.png")
44 //use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/rbc_single_oblong_2.png")
45 use img = new Image<Bgr, byte>("../../../../src/Tests_hough/images/two_rbc_1.png")
46
47 let result = ImageAnalysis.doAnalysis img config
48
49 display mainWindow result.img
50 mainWindow.Root.Show()
51
52 app.Run() |> ignore