From: Greg Burri Date: Sat, 4 Nov 2017 19:42:21 +0000 (+0100) Subject: Use of roman number to identify images. X-Git-Tag: 1.0.13~14 X-Git-Url: http://git.euphorik.ch/?a=commitdiff_plain;ds=inline;h=2f335ec0c462159ed9f424e3793b7af290404062;p=master-thesis.git Use of roman number to identify images. --- diff --git a/.gitignore b/.gitignore index 4a6c7e8..aaa6326 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ obj/ packages/ .vs *.exe -*.suo \ No newline at end of file +*.suo +Images +Scripts diff --git a/Parasitemia/ParasitemiaUI/Analysis.fs b/Parasitemia/ParasitemiaUI/Analysis.fs index 13ce48b..485ddfd 100644 --- a/Parasitemia/ParasitemiaUI/Analysis.fs +++ b/Parasitemia/ParasitemiaUI/Analysis.fs @@ -57,7 +57,7 @@ let showWindow (parent : Window) (state : State.State) : bool = let imageSourceSelection = Views.ImageSourceSelection (Tag = srcImg, Margin = Thickness 3.) imageSourceSelection.Tag <- srcImg - imageSourceSelection.txtImageNumber.Text <- string srcImg.Num + imageSourceSelection.txtImageNumber.Text <- string srcImg.RomanNum let height = srcImg.Img.Height * width / srcImg.Img.Width imageSourceSelection.imagePreview.Source <- BitmapSourceConvert.ToBitmapSource (srcImg.Img.Resize (width, height, Emgu.CV.CvEnum.Inter.Cubic)) imageSourceSelection.chkSelection.IsChecked <- Nullable (srcImg.DateLastAnalysis.Ticks = 0L) @@ -125,7 +125,7 @@ let showWindow (parent : Window) (state : State.State) : bool = for srcImg, selected, parameters in imagesParameters do srcImg.Config.Parameters <- parameters // Save parameters. if selected then - yield string srcImg.Num, srcImg.Config, srcImg.Img + yield string srcImg.RomanNum, srcImg.Config, srcImg.Img ] if imagesToProcess.IsEmpty then @@ -148,7 +148,7 @@ let showWindow (parent : Window) (state : State.State) : bool = match maybeResults with | Some results -> for id, cells in results do - state.SetResult (int id) cells + state.SetResult id cells Logger.Log.Info "All analyses terminated successfully" atLeastOneAnalysisPerformed <- true analysisPerformed <- true diff --git a/Parasitemia/ParasitemiaUI/GUI.fs b/Parasitemia/ParasitemiaUI/GUI.fs index d78c202..f305687 100644 --- a/Parasitemia/ParasitemiaUI/GUI.fs +++ b/Parasitemia/ParasitemiaUI/GUI.fs @@ -342,11 +342,11 @@ let run (defaultConfig : Config) (fileToOpen : string option) = updateGlobalParasitemia () // Update image numbers. - win.stackPreviews.Children |> Seq.cast |> Seq.iter (fun imgPreview -> imgPreview.txtImageNumber.Text <- (imgPreview.Tag :?> SourceImage).Num.ToString ()) + win.stackPreviews.Children |> Seq.cast |> Seq.iter (fun imgPreview -> imgPreview.txtImageNumber.Text <- (imgPreview.Tag :?> SourceImage).RomanNum) ) imgCtrl.Tag <- srcImg - imgCtrl.txtImageNumber.Text <- string srcImg.Num + imgCtrl.txtImageNumber.Text <- string srcImg.RomanNum let width = 200 let height = srcImg.Img.Height * width / srcImg.Img.Width imgCtrl.imagePreview.Source <- BitmapSourceConvert.ToBitmapSource (srcImg.Img.Resize (width, height, Emgu.CV.CvEnum.Inter.Cubic)) diff --git a/Parasitemia/ParasitemiaUI/SourceImage.fs b/Parasitemia/ParasitemiaUI/SourceImage.fs index 2330227..7b3de18 100644 --- a/Parasitemia/ParasitemiaUI/SourceImage.fs +++ b/Parasitemia/ParasitemiaUI/SourceImage.fs @@ -25,16 +25,19 @@ type SourceImage (num : int, name : string, config : ParasitemiaCore.Config.Conf let infectedRBColor = Color.FromRgb (255uy, 0uy, 40uy) // Red with a bit of blue. let updateAverageRBCSize () = - averageRBCSize <- - rbcs - |> List.collect (fun rbc -> [ rbc.size.Width; rbc.size.Height ]) - |> List.average + if List.isEmpty rbcs |> not then + averageRBCSize <- + rbcs + |> List.collect (fun rbc -> [ rbc.size.Width; rbc.size.Height ]) + |> List.average do updateAverageRBCSize () member this.Num with get () = num and set value = num <- value + member this.RomanNum = Utils.toRomanNumber this.Num + member this.Name with get () = name and set value = name <- value member this.Config = config @@ -45,7 +48,9 @@ type SourceImage (num : int, name : string, config : ParasitemiaCore.Config.Conf member this.RBCs with get () = rbcs - and set value = rbcs <- value + and set value = + rbcs <- value + updateAverageRBCSize () member this.ImageParasitemia : int * int = List.length rbcs, diff --git a/Parasitemia/ParasitemiaUI/State.fs b/Parasitemia/ParasitemiaUI/State.fs index 129e6a6..befbdec 100644 --- a/Parasitemia/ParasitemiaUI/State.fs +++ b/Parasitemia/ParasitemiaUI/State.fs @@ -89,8 +89,8 @@ type State (defaultConfig : ParasitemiaCore.Config.Config) = srcImg.Name <- name alteredSinceLastSave <- true - member this.SetResult (imgNum : int) (result : ParasitemiaCore.Types.AnalysisResult) = - let sourceImage = sourceImages.Find (fun srcImg -> srcImg.Num = imgNum) + member this.SetResult (imgId : string) (result : ParasitemiaCore.Types.AnalysisResult) = + let sourceImage = sourceImages.Find (fun srcImg -> srcImg.RomanNum = imgId) let w = sourceImage.Img.Width let h = sourceImage.Img.Height diff --git a/Parasitemia/ParasitemiaUI/Utils.fs b/Parasitemia/ParasitemiaUI/Utils.fs index e7c9784..9f51436 100644 --- a/Parasitemia/ParasitemiaUI/Utils.fs +++ b/Parasitemia/ParasitemiaUI/Utils.fs @@ -61,6 +61,38 @@ let sensorSizes : SensorSize list = saveSensorSizesToFile defaultSensorSizes defaultSensorSizes +let toRomanNumber (v : int) : string = + let rec decompose (v : int) : string = + if v >= 1000 then + "M" + decompose (v - 1000) + elif v >= 900 then + "CM" + decompose (v - 900) + elif v >= 500 then + "D" + decompose (v - 500) + elif v >= 400 then + "CD" + decompose (v - 400) + elif v >= 100 then + "C" + decompose (v - 100) + elif v >= 90 then + "XC" + decompose (v - 90) + elif v >= 50 then + "L" + decompose (v - 50) + elif v >= 40 then + "XL" + decompose (v - 40) + elif v >= 10 then + "X" + decompose (v - 10) + elif v >= 9 then + "IX" + decompose (v - 9) + elif v >= 5 then + "V" + decompose (v - 5) + elif v >= 4 then + "IV" + decompose (v - 4) + elif v >= 1 then + "I" + decompose (v - 1) + else + "" + decompose v + let argsHelp = let programName = System.AppDomain.CurrentDomain.FriendlyName "Usage of Parasitemia:\n" +