X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FClassifier.fs;h=b01a0412deceecaa31da61da83e78210f8a35a24;hb=a498bc4223a22cd38b91b3348912301e15c077ae;hp=9b247f43db4599e702ce0b469659d5e881773765;hpb=2d712781def419c9acc98368f7102b19b064f16d;p=master-thesis.git diff --git a/Parasitemia/ParasitemiaCore/Classifier.fs b/Parasitemia/ParasitemiaCore/Classifier.fs index 9b247f4..b01a041 100644 --- a/Parasitemia/ParasitemiaCore/Classifier.fs +++ b/Parasitemia/ParasitemiaCore/Classifier.fs @@ -5,7 +5,6 @@ open System.Collections.Generic open System.Drawing open Emgu.CV -open Emgu.CV.Structure open Types open Utils @@ -70,16 +69,16 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi // Yield 'false' when the point is owned by another ellipse. if case1 then - yield sign delta <> sign delta' || Utils.squaredDistanceTwoPoints c p' > Utils.squaredDistanceTwoPoints c p + sign delta <> sign delta' || Utils.squaredDistanceTwoPoints c p' > Utils.squaredDistanceTwoPoints c p else - yield sign delta = sign delta' && Utils.squaredDistanceTwoPoints c p' < Utils.squaredDistanceTwoPoints c p + sign delta = sign delta' && Utils.squaredDistanceTwoPoints c p' < Utils.squaredDistanceTwoPoints c p else - yield case1 + case1 elif e.State = CellState.Peculiar then // A peculiar always win against a RBC. - yield true + true else - yield not <| e'.Contains p.X p.Y + not <| e'.Contains p.X p.Y } |> Seq.forall id @@ -91,7 +90,7 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi if e.State <> CellState.Removed then tree.Search (searchRegion e) // We only keep the ellipses touching 'e'. - |> List.choose ( + |> Seq.choose ( fun otherE -> if e <> otherE then match EEOver.EEOverlapArea e otherE with @@ -105,6 +104,7 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi else None ) + |> List.ofSeq else [] @@ -121,7 +121,7 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi let globalStdDeviation = MathNet.Numerics.Statistics.Statistics.PopulationStandardDeviation (seq { for y in 0 .. h - 1 do for x in 0 .. w - 1 do - yield float imgData.[y, x, 0] }) + float imgData.[y, x, 0] }) for e in ellipses do if not e.Removed then @@ -132,7 +132,7 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi for y in (if minY < 0 then 0 else minY) .. (if maxY >= h then h - 1 else maxY) do for x in (if minX < 0 then 0 else minX) .. (if maxX >= w then w - 1 else maxX) do if shrinkedE.Contains (float32 x) (float32 y) then - yield float imgData.[y, x, 0] }) + float imgData.[y, x, 0] }) if stdDeviation > globalStdDeviation * config.Parameters.standardDeviationMaxRatio then e.Removed <- true *) @@ -218,7 +218,7 @@ let findCells (ellipses : Ellipse list) (parasites : ParasitesMarker.Result) (wi seq { for parasitePixel in parasitePixels do if nucleusPixels.Exists (fun p -> pown (p.X - parasitePixel.X) 2 + pown (p.Y - parasitePixel.Y) 2 <= diameterParasiteSquared) then - yield 1 + 1 } |> Seq.sum else 0