projects
/
master-thesis.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d3fdf4b
)
Doc + cleaning.
author
Greg Burri
<greg.burri@gmail.com>
Sat, 30 Jan 2016 22:03:10 +0000
(23:03 +0100)
committer
Greg Burri
<greg.burri@gmail.com>
Sat, 30 Jan 2016 22:03:10 +0000
(23:03 +0100)
Parasitemia/ParasitemiaCore/Analysis.fs
patch
|
blob
|
history
Parasitemia/ParasitemiaCore/Ellipse.fs
patch
|
blob
|
history
Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
patch
|
blob
|
history
Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs
patch
|
blob
|
history
Parasitemia/ParasitemiaUI/Analysis.fs
patch
|
blob
|
history
Parasitemia/ParasitemiaUI/Program.fs
patch
|
blob
|
history
diff --git
a/Parasitemia/ParasitemiaCore/Analysis.fs
b/Parasitemia/ParasitemiaCore/Analysis.fs
index
c894fc4
..
e83977a
100644
(file)
--- a/
Parasitemia/ParasitemiaCore/Analysis.fs
+++ b/
Parasitemia/ParasitemiaCore/Analysis.fs
@@
-46,6
+46,7
@@
let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
let logWithName mess = Log.User(buildLogWithName mess)
let inline logTimeWithName (text: string) (f: unit -> 'a option) : 'a option = Log.LogWithTime((buildLogWithName text), Severity.USER, f)
let logWithName mess = Log.User(buildLogWithName mess)
let inline logTimeWithName (text: string) (f: unit -> 'a option) : 'a option = Log.LogWithTime((buildLogWithName text), Severity.USER, f)
+ // Monadic construction to be able to abort the progress when running.
maybe {
do! report 0
maybe {
do! report 0
@@
-53,10
+54,10
@@
let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
use img_float = img.Convert<Bgr, float32>()
use img_float = img.Convert<Bgr, float32>()
- use img_RBC = img_float.[1] //
mergeChannelsWithProjection img_float config.Parameters.averageColor_RBC config.Parameters.averageColor_BG 255
.
+ use img_RBC = img_float.[1] //
Green
.
use img_RBC_filtered = gaussianFilter img_RBC config.LPFStandardDeviationRBC
use img_RBC_filtered = gaussianFilter img_RBC config.LPFStandardDeviationRBC
- use img_parasites = img_float.[2] //
mergeChannelsWithProjection img_float config.Parameters.averageColor_Parasite config.Parameters.averageColor_RBC 255
.
+ use img_parasites = img_float.[2] //
Red
.
use img_parasites_filtered = gaussianFilter img_parasites config.LPFStandardDeviationParasite
logWithName (sprintf "Nominal erythrocyte diameter: %A" config.RBCRadiusByResolution)
use img_parasites_filtered = gaussianFilter img_parasites config.LPFStandardDeviationParasite
logWithName (sprintf "Nominal erythrocyte diameter: %A" config.RBCRadiusByResolution)
@@
-137,10
+138,10
@@
let doAnalysis (img: Image<Bgr, byte>) (name: string) (config: Config) (reportPr
Drawing.drawCells imgCells' true cells
IO.saveImg imgCells' (buildFileName " - cells - full.png")
Drawing.drawCells imgCells' true cells
IO.saveImg imgCells' (buildFileName " - cells - full.png")
- let filtered
Green
Maxima = gaussianFilter img_RBC config.LPFStandardDeviationRBC
- for m in findMaxima filtered
Green
Maxima do
- Drawing.drawPoints filtered
Green
Maxima m 255.f
- IO.saveImg filtered
Green
Maxima (buildFileName " - filtered - maxima.png")
+ let filtered
RBC
Maxima = gaussianFilter img_RBC config.LPFStandardDeviationRBC
+ for m in findMaxima filtered
RBC
Maxima do
+ Drawing.drawPoints filtered
RBC
Maxima m 255.f
+ IO.saveImg filtered
RBC
Maxima (buildFileName " - filtered - maxima.png")
IO.saveImg imgWhitoutParasite (buildFileName " - filtered closed stain.png")
IO.saveImg imgWithoutNucleus (buildFileName " - filtered closed infection.png")
IO.saveImg imgWhitoutParasite (buildFileName " - filtered closed stain.png")
IO.saveImg imgWithoutNucleus (buildFileName " - filtered closed infection.png")
@@
-182,9
+183,14
@@
let doMultipleAnalysis (imgs: (string * Config * Image<Bgr, byte>) list) (report
imgs
|> PSeq.choose (
fun (id, config, img) ->
imgs
|> PSeq.choose (
fun (id, config, img) ->
- match doAnalysis img id config (Some (fun p -> reportProgressImg id p)) with
- | Some result -> Some (id, result)
- | None -> None)
+ try
+ match doAnalysis img id config (Some (fun p -> reportProgressImg id p)) with
+ | Some result -> Some (id, result)
+ | None -> None
+ with
+ | ex ->
+ Log.Error("Analysis {0} failed: {1}", id, ex)
+ None)
|> PSeq.withDegreeOfParallelism n
|> PSeq.toList
|> PSeq.withDegreeOfParallelism n
|> PSeq.toList
diff --git
a/Parasitemia/ParasitemiaCore/Ellipse.fs
b/Parasitemia/ParasitemiaCore/Ellipse.fs
index
cf94be2
..
e95cf27
100644
(file)
--- a/
Parasitemia/ParasitemiaCore/Ellipse.fs
+++ b/
Parasitemia/ParasitemiaCore/Ellipse.fs
@@
-181,7
+181,7
@@
let find (edges: Matrix<byte>)
if edgesData.[i, j] = 1uy
then currentElements.Add(Point(j, i))
if edgesData.[i, j] = 1uy
then currentElements.Add(Point(j, i))
- if currentElements.Count >=
10
+ if currentElements.Count >=
nbPickElementsMin
then
let mutable nbOfPicks = (float currentElements.Count) * factorNbMaxPick |> int
let mutable nbOfValidPicks = (float currentElements.Count) * factorNbValidPick |> int
then
let mutable nbOfPicks = (float currentElements.Count) * factorNbMaxPick |> int
let mutable nbOfValidPicks = (float currentElements.Count) * factorNbValidPick |> int
diff --git
a/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
b/Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
index
a1b6033
..
3980120
100644
(file)
--- a/
Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
+++ b/
Parasitemia/ParasitemiaCore/ImgTools/Edges.fs
@@
-87,9
+87,6
@@
let find (img: Image<Gray, float32>) : Matrix<byte> * Matrix<float32> * Matrix<f
// suppressMConnections nms // It's not helpful for the rest of the process (ellipse detection).
// suppressMConnections nms // It's not helpful for the rest of the process (ellipse detection).
- IO.saveMat magnitudes "magnitudes.png"
- IO.saveMat nms "nms.png"
-
let edges = new Matrix<byte>(xGradient.Size)
let edgesData = edges.Data
let edges = new Matrix<byte>(xGradient.Size)
let edgesData = edges.Data
diff --git
a/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs
b/Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs
index
0510bc8
..
0949713
100644
(file)
--- a/
Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs
+++ b/
Parasitemia/ParasitemiaCore/ImgTools/ImgTools.fs
@@
-6,6
+6,12
@@
open System.Drawing
open Emgu.CV
open Emgu.CV.Structure
open Emgu.CV
open Emgu.CV.Structure
+/// <summary>
+/// Normalize an image between 0 and 'upperLimit'.
+/// FIXME: use to many memory.
+/// </summary>
+/// <param name="img"></param>
+/// <param name="upperLimit"></param>
let normalize (img: Image<Gray, float32>) (upperLimit: float) : Image<Gray, float32> =
let min = ref [| 0.0 |]
let minLocation = ref <| [| Point() |]
let normalize (img: Image<Gray, float32>) (upperLimit: float) : Image<Gray, float32> =
let min = ref [| 0.0 |]
let minLocation = ref <| [| Point() |]
diff --git
a/Parasitemia/ParasitemiaUI/Analysis.fs
b/Parasitemia/ParasitemiaUI/Analysis.fs
index
5bb3500
..
2ff0b1e
100644
(file)
--- a/
Parasitemia/ParasitemiaUI/Analysis.fs
+++ b/
Parasitemia/ParasitemiaUI/Analysis.fs
@@
-128,17
+128,18
@@
let showWindow (parent: Window) (state: State.State) : bool =
| Some results ->
for id, cells in results do
state.SetResult (int id) cells
| Some results ->
for id, cells in results do
state.SetResult (int id) cells
-
- win.Root.Dispatcher.Invoke(fun () ->
- win.stackSourceImagesSelection.IsEnabled <- true
- win.butStart.IsEnabled <- true
- win.butClose.Content <- "Close"
- updateSourceImages ())
-
Logger.Log.User("All analyses terminated successfully")
atLeastOneAnalysisPerformed <- true
analysisPerformed <- true
Logger.Log.User("All analyses terminated successfully")
atLeastOneAnalysisPerformed <- true
analysisPerformed <- true
- | None -> ())
+ | None ->
+ Logger.Log.User("Analysis aborted")
+
+ win.Root.Dispatcher.Invoke(fun () ->
+ win.progress.Value <- if maybeResults.IsSome then 100. else 0.
+ win.stackSourceImagesSelection.IsEnabled <- true
+ win.butStart.IsEnabled <- true
+ win.butClose.Content <- "Close"
+ updateSourceImages ()))
} |> Async.Start
| _ -> ())
} |> Async.Start
| _ -> ())
@@
-151,5
+152,6
@@
let showWindow (parent: Window) (state: State.State) : bool =
lock monitor (fun () ->
if not analysisPerformed
then
lock monitor (fun () ->
if not analysisPerformed
then
+ // To cancel the current analysis if one is running on the next call to the progress function.
analysisCancelled <- true
atLeastOneAnalysisPerformed)
analysisCancelled <- true
atLeastOneAnalysisPerformed)
diff --git
a/Parasitemia/ParasitemiaUI/Program.fs
b/Parasitemia/ParasitemiaUI/Program.fs
index
feab9ec
..
ce7cdd4
100644
(file)
--- a/
Parasitemia/ParasitemiaUI/Program.fs
+++ b/
Parasitemia/ParasitemiaUI/Program.fs
@@
-96,6
+96,6
@@
let main args =
result
with
result
with
- |
_ as
ex ->
+ | ex ->
Log.Fatal("Error: {0}", ex)
1
\ No newline at end of file
Log.Fatal("Error: {0}", ex)
1
\ No newline at end of file