open MatchingEllipses
open Const
+// This is a ratio of the biggest radius.
+let minimumDistanceBetweenDrawnPoints = 0.6
+
/// <summary>
/// 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.
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
if diff > PI || (diff < 0.f && diff > -PI)
then
- None
+ Some (m1, m2)
else
- Some (m1, m2)
+ None
let find (edges: Matrix<byte>)
(xGradient: Matrix<float32>)
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