Remove ellipses touching the edges.
[master-thesis.git] / Parasitemia / Parasitemia / MatchingEllipses.fs
index afc4ab7..0964953 100644 (file)
@@ -50,12 +50,14 @@ type MatchingEllipses (radiusMin: float) =
                 if not other.Processed
                 then
                     let areaOther = other.Ellipse.Area
-                    let commonArea = EEOver.EEOverlapArea e.Ellipse other.Ellipse
-                    let matchingScore = 2.0 * commonArea / (areaE + areaOther)
-                    if matchingScore >= matchingScoreThreshold1
-                    then
-                        other.AddMatchingScore(matchingScore)
-                        e.AddMatchingScore(matchingScore)
+                    match EEOver.EEOverlapArea e.Ellipse other.Ellipse with
+                    | Some (commonArea, _, _) ->
+                        let matchingScore = 2.0 * commonArea / (areaE + areaOther)
+                        if matchingScore >= matchingScoreThreshold1
+                        then
+                            other.AddMatchingScore(matchingScore)
+                            e.AddMatchingScore(matchingScore)
+                    | _ -> ()
 
         // 3) Sort ellipses by their score.
         ellipses.Sort(fun e1 e2 -> e2.MatchingScore.CompareTo(e1.MatchingScore))
@@ -87,8 +89,6 @@ type MatchingEllipses (radiusMin: float) =
                             other.Removed <- true
         ellipses.RemoveAll(fun e -> e.Removed) |> ignore
 
-        dprintfn "Number of ellipse: %A" ellipses.Count
-
         List.ofSeq ellipses |> List.map (fun e -> e.Ellipse)