X-Git-Url: http://git.euphorik.ch/?p=master-thesis.git;a=blobdiff_plain;f=Parasitemia%2FParasitemiaCore%2FEllipse.fs;h=db23ece8976d2e82a53c42533f26d787a74936a5;hp=4e4823024e18bc4317c9c6413b8dd706a76597a1;hb=04d4504e7b248a82ddfc1a41d325e59d24146590;hpb=276f1c9741f196e022bdbd175b4f6ef0ebb6367d diff --git a/Parasitemia/ParasitemiaCore/Ellipse.fs b/Parasitemia/ParasitemiaCore/Ellipse.fs index 4e48230..db23ece 100644 --- a/Parasitemia/ParasitemiaCore/Ellipse.fs +++ b/Parasitemia/ParasitemiaCore/Ellipse.fs @@ -14,6 +14,9 @@ open Config open MatchingEllipses open Const +// This is a ratio of the biggest radius. +let minimumDistanceBetweenDrawnPoints = 0.6 + /// /// Try to build an ellipse from three points and two tangents passing by the first and the second point. /// 'Ellipse.A' is always equal or greater than Ellipse.B. @@ -76,28 +79,17 @@ let ellipse (p1x: float) (p1y: float) (m1: float) (p2x: float) (p2y: float) (m2: let private vectorRotation (p1x: float32) (p1y: float32) (v1x: float32) (v1y: float32) (px: float32) (py: float32) : float32 = - let mutable rotation = 1.f if p1y > py then - if v1x > 0.f - then - rotation <- -1.f + if v1x > 0.f then -1.f else 1.f elif p1y < py then - if v1x < 0.f - then - rotation <- -1.f + if v1x < 0.f then -1.f else 1.f elif p1x > px then - if v1y < 0.f - then - rotation <- -1.f - elif p1x < px - then - if v1y > 0.f - then - rotation <- -1.f - rotation + if v1y < 0.f then -1.f else 1.f + else // p1x < px + if v1y > 0.f then -1.f else 1.f let private areVectorsValid (p1x: float32) (p1y: float32) (p2x: float32) (p2y: float32) (v1x: float32) (v1y: float32) (v2x: float32) (v2y: float32) : (float32 * float32) option = let m1 = -v1x / v1y @@ -125,9 +117,9 @@ let private areVectorsValid (p1x: float32) (p1y: float32) (p2x: float32) (p2y: f if diff > PI || (diff < 0.f && diff > -PI) then - None + Some (m1, m2) else - Some (m1, m2) + None let find (edges: Matrix) (xGradient: Matrix) @@ -145,7 +137,7 @@ let find (edges: Matrix) let radiusTolerance = (r2 - r1) * 0.2f - let squaredMinimumDistance = (float r2 / 1.5) ** 2. + let squaredMinimumDistance = (float config.RBCRadius.Pixel * minimumDistanceBetweenDrawnPoints) ** 2. let inline squaredDistance x1 y1 x2 y2 = (x1 - x2) ** 2. + (y1 - y2) ** 2. let h = edges.Height