From: Greg Burri Date: Thu, 7 Jan 2016 17:34:45 +0000 (+0100) Subject: * Add area granulometry (not used for the moment) X-Git-Tag: 1.0.11~62 X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=3ddaf64dc5ba6a7066a279ad75b9a1ee72194639;p=master-thesis.git * Add area granulometry (not used for the moment) * beginning of a little GUI. --- diff --git a/Parasitemia/Parasitemia.sln b/Parasitemia/Parasitemia.sln index aeabd42..ea32a4b 100644 --- a/Parasitemia/Parasitemia.sln +++ b/Parasitemia/Parasitemia.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22823.1 +VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Parasitemia", "Parasitemia\Parasitemia.fsproj", "{70838E65-F211-44FC-B28F-0ED1CA6E850F}" EndProject @@ -10,15 +10,20 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + DebugGUI|Any CPU = DebugGUI|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70838E65-F211-44FC-B28F-0ED1CA6E850F}.DebugGUI|Any CPU.ActiveCfg = DebugGUI|Any CPU + {70838E65-F211-44FC-B28F-0ED1CA6E850F}.DebugGUI|Any CPU.Build.0 = DebugGUI|Any CPU {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Release|Any CPU.ActiveCfg = Release|Any CPU {70838E65-F211-44FC-B28F-0ED1CA6E850F}.Release|Any CPU.Build.0 = Release|Any CPU {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {314FD78E-870E-4794-BB16-EA4586F2ABDB}.DebugGUI|Any CPU.ActiveCfg = Debug|Any CPU + {314FD78E-870E-4794-BB16-EA4586F2ABDB}.DebugGUI|Any CPU.Build.0 = Debug|Any CPU {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Release|Any CPU.ActiveCfg = Release|Any CPU {314FD78E-870E-4794-BB16-EA4586F2ABDB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/Parasitemia/Parasitemia/Classifier.fs b/Parasitemia/Parasitemia/Classifier.fs index 341f7c9..3a679e7 100644 --- a/Parasitemia/Parasitemia/Classifier.fs +++ b/Parasitemia/Parasitemia/Classifier.fs @@ -229,4 +229,5 @@ let findCells (ellipses: Ellipse list) (parasites: ParasitesMarker.Result) (img: Some { cellClass = cellClass center = Point(roundInt e.Cx, roundInt e.Cy) + stainArea = stainPixels elements = elements }) diff --git a/Parasitemia/Parasitemia/Const.fs b/Parasitemia/Parasitemia/Const.fs new file mode 100644 index 0000000..0d2e52e --- /dev/null +++ b/Parasitemia/Parasitemia/Const.fs @@ -0,0 +1,4 @@ +module Const + +// TODO: try with a literal and check performance. +let PI = float32 System.Math.PI \ No newline at end of file diff --git a/Parasitemia/Parasitemia/GUI/GUI.fs b/Parasitemia/Parasitemia/GUI/GUI.fs new file mode 100644 index 0000000..cf7ed67 --- /dev/null +++ b/Parasitemia/Parasitemia/GUI/GUI.fs @@ -0,0 +1,76 @@ +module Parasitemia.GUI + +open System.IO +open System.Windows +open System.Windows.Media +open System.Windows.Markup +open System.Windows.Shapes +open System.Windows.Controls +open System.Drawing +open System.Diagnostics +open Microsoft.Win32 // For the common dialogs. + +open Emgu.CV +open Emgu.CV.Structure +open Emgu.CV.WPF + +open Config + +let run (defaultConfig: Config) = + let app = new Application() + let mainWindow = Views.MainWindow() + let ctrl (name: string): 'a = + mainWindow.Root.FindName(name) :?> 'a + + // Utils.log <- (fun m -> log mainWindow m) + + let state = State.State() + + let exit: Controls.MenuItem = ctrl "menuExit" + let save: Controls.MenuItem = ctrl "menuSave" + let load: Controls.MenuItem = ctrl "menuOpen" + + let txtPatient: Controls.TextBox = ctrl "txtPatient" + + + let synchronizeState () = + state.PatientID <- txtPatient.Text + + let synchronizeView () = + txtPatient.Text <- state.PatientID + + exit.Click.AddHandler(fun obj args -> mainWindow.Root.Close()) + save.Click.AddHandler(fun obj args -> + synchronizeState () + if state.FilePath = "" + then + let dialog = SaveFileDialog(AddExtension = true, DefaultExt = Pia.extension, Filter = Pia.filter); + let res = dialog.ShowDialog() + if res.HasValue && res.Value + then + state.FilePath <- dialog.FileName + state.Save() + else + state.Save()) + + load.Click.AddHandler(fun obj args -> + // TODO: if current state not saved and not empty, ask to save it. + let dialog = OpenFileDialog(Filter = Pia.filter) + let res = dialog.ShowDialog() + if res.HasValue && res.Value + then + state.FilePath <- dialog.FileName + state.Load() + synchronizeView ()) + + (*let txtPatient: Controls.TextBox = ctrl "txtPatient" + txtPatient.TextChanged.AddHandler(fun obj args -> + state.PatientID <- txtPatient.Text)*) + + (*saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; + saveFileDialog1.FilterIndex = 2 ; + saveFileDialog1.RestoreDirectory = true ;*) + + // display mainWindow img + mainWindow.Root.Show() + app.Run() \ No newline at end of file diff --git a/Parasitemia/Parasitemia/GUI/MainWindow.xaml b/Parasitemia/Parasitemia/GUI/MainWindow.xaml new file mode 100644 index 0000000..5b7a3c5 --- /dev/null +++ b/Parasitemia/Parasitemia/GUI/MainWindow.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Parasitemia/Parasitemia/GUI/MainWindow.xaml.fs b/Parasitemia/Parasitemia/GUI/MainWindow.xaml.fs new file mode 100644 index 0000000..62c35a4 --- /dev/null +++ b/Parasitemia/Parasitemia/GUI/MainWindow.xaml.fs @@ -0,0 +1,6 @@ +namespace Parasitemia.Views + +open FsXaml + +type MainWindow = XAML<"GUI/MainWindow.xaml"> + diff --git a/Parasitemia/Parasitemia/GUI/NumericUpDown.xaml b/Parasitemia/Parasitemia/GUI/NumericUpDown.xaml new file mode 100644 index 0000000..ae20a5b --- /dev/null +++ b/Parasitemia/Parasitemia/GUI/NumericUpDown.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + +