module ParasitemiaCore.MatchingEllipses
-open System
open System.Drawing
-open System.Linq
-open System.Collections
open System.Collections.Generic
open Types
member this.Y = this.Ellipse.Cy
type MatchingEllipses (radius : float32) =
- let ellipses = List<EllipseScoreFlaggedKd>()
+ let ellipses = List<EllipseScoreFlaggedKd> ()
member this.Add (e : Ellipse) =
- ellipses.Add(EllipseScoreFlaggedKd(0.f, e))
+ ellipses.Add (EllipseScoreFlaggedKd (0.f, e))
member this.Ellipses : Ellipse list =
List.ofSeq ellipses |> List.map (fun e -> e.Ellipse)
// Because of approximation error, see https://github.com/chraibi/EEOver/issues/4
when overlapArea - areaE < 1.f && overlapArea - areaOther < 1.f ->
let matchingScore = (2.f * overlapArea / (areaE + areaOther)) ** matchingScorePower
- other.AddMatchingScore(matchingScore)
- e.AddMatchingScore(matchingScore)
+ other.AddMatchingScore matchingScore
+ e.AddMatchingScore matchingScore
| _ -> ()
// 3) Remove ellipses whose center is near the center of another ellipse with a better score.
for other in tree.Search window do
if not other.Removed && e.MatchingScore > other.MatchingScore then
// Case where ellipses are too close.
- if distanceTwoPoints (PointF(e.Ellipse.Cx, e.Ellipse.Cy)) (PointF(other.Ellipse.Cx, other.Ellipse.Cy)) < minimumDistanceFromCenterRadiusFactor * e.Ellipse.B then
+ if distanceTwoPoints (PointF (e.Ellipse.Cx, e.Ellipse.Cy)) (PointF (other.Ellipse.Cx, other.Ellipse.Cy)) < minimumDistanceFromCenterRadiusFactor * e.Ellipse.B then
other.Removed <- true
else
// Case where ellipses are overlapped.
ellipses
|> List.ofSeq
|> List.filter (fun e -> not e.Removed)
- |> List.sortWith (fun e1 e2 -> e2.MatchingScore.CompareTo(e1.MatchingScore))
+ |> List.sortWith (fun e1 e2 -> e2.MatchingScore.CompareTo e1.MatchingScore)
|> List.map (fun e -> e.Ellipse)