Goal
Detect ellipse centres in a grayscale image where circular structures appear as ellipses under bounded perspective projection. Output: a real-valued response map whose local maxima localise ellipse centres, together with the five ellipse parameters recovered from the sampled affine transform that produced each peak. The method is specific to ellipses generated by the constrained affine group — equivalently, perspective foreshortening of approximately circular structures. Each image pixel votes along a direction obtained by warping its gradient through for each sampled , accumulating an FRS-style orientation-and-magnitude projection per radius and per , then reducing the stack of per- responses by per-pixel maximum. Cost is for a -pixel image with detection radii and sampled affine hypotheses.
Algorithm
Let denote the grayscale image on pixel domain . Let denote the image gradient at pixel . Let denote the set of detection radii in pixels. Let denote the radial strictness parameter. Let denote the gradient magnitude threshold. Let denote the ellipse orientation angle, the major semi-axis, the minor semi-axis. Let denote the 2-D rotation matrix. Let denote the anisotropic scale matrix; the symbol is used in place of the paper's to avoid collision with the FRS response. Let denote the 90° rotation that relates an ellipse tangent to the inward normal direction. Let denote a finite grid of sampled transforms from , each parametrised by . Let and denote the FRS orientation and magnitude projection images for radius and transform . Let denote the per-radius normalising factor for the FRS accumulation; in GFRS it depends additionally on the current .
The set of affine transforms that map a unit circle to an ellipse with semi-axes and orientation :
Each maps the unit circle to the ellipse , with axes of length and rotated by .
For a pixel on the ellipse boundary with gradient , the corrected voting direction toward the ellipse centre under transform is:
Here is the 90° rotation relating the ellipse tangent to the inward normal direction; the chain maps the circular-symmetry voting direction back through the ellipse parametrisation, and accounts for the fact that the image gradient already estimates the local normal rather than the tangent. The closed-form matrix with , is:
When the matrix reduces to the identity, recovering the unmodified FRS gradient direction. The determinant of is for all .
The GFRS-corrected positively- and negatively-affected pixels at radius are:
These replace the FRS votes ; for circular structures () the two formulations coincide.
For a fixed , the FRS response at radius is , where
with the clipped orientation projection, recomputed for the current pair to compensate for the varying ellipse perimeter length, and an anisotropic Gaussian kernel aligned to . The per- response summed over radii is:
The isotropic Gaussian used by FRS is replaced by an anisotropic kernel because voting-location error magnitude scales with , which depends on the ellipse axis lengths; an isotropic kernel over-smooths along the minor axis and under-smooths along the major axis for elongated ellipses.
The combined response is the per-pixel maximum over all sampled transforms:
Local maxima of are the detected ellipse-centre candidates; the corresponding at each peak supplies the ellipse parameters .
Procedure
- Compute the image gradient at every pixel.
- Initialise across .
- For each sampled :
- Precompute the closed-form matrix .
- Recompute the normalising factor for the pair .
- Initialise across .
- For each radius :
- Initialise and across .
- For each pixel with , compute ; compute corrected vote offsets ; update and at both affected pixels.
- Form from the clipped, normalised projections.
- Construct the anisotropic Gaussian aligned to .
- Accumulate .
- Update at every pixel.
- Apply non-maximum suppression on to extract candidate ellipse centres.
flowchart LR
A["Image I"] --> B["Gradient ∇I"]
B --> C["For each Gᵢ"]
C --> D["Corrected votes\nV̂ = G M G⁻¹ M⁻¹ ∇I"]
D --> E["FRS accumulate\nper radius n"]
E --> F["Per-Gᵢ response\nS_{Gᵢ} (anisotropic smooth)"]
F --> G["Per-pixel max\nover i"]
G --> H["S_GFRS"]
H --> I["Local maxima\n→ ellipse centres"]
Implementation
The GFRS vote-correction kernel in Rust: given a gradient at one pixel and one , compute the corrected integer vote offset .
/// Compute the GFRS corrected vote offset for one pixel.
///
/// Closed form for A = G M G⁻¹ M⁻¹ with c = cos θ, s = sin θ:
///
/// A = (1/ab) · ⎡ a²c² + b²s² cs(a²−b²) ⎤
/// ⎣ cs(a²−b²) a²s² + b²c²⎦
///
/// Derivation: G = R·D, G⁻¹ = D⁻¹R⁻¹, M = [[0,1],[-1,0]], M⁻¹ = [[0,-1],[1,0]].
/// Multiplying out G·M·G⁻¹·M⁻¹ and collecting terms yields the matrix above.
/// When a = b the matrix collapses to I and GFRS recovers unmodified FRS voting.
fn gfrs_vote_offset(gx: f32, gy: f32, theta: f32, a: f32, b: f32, n: i32) -> (i32, i32) {
let c = theta.cos();
let s = theta.sin();
let inv_ab = 1.0 / (a * b);
// Rows of A:
// [(a²c² + b²s²)/ab, cs(a²−b²)/ab]
// [cs(a²−b²)/ab, (a²s² + b²c²)/ab]
let a11 = (a * a * c * c + b * b * s * s) * inv_ab;
let a12 = c * s * (a * a - b * b) * inv_ab;
let a21 = a12; // off-diagonal entries are equal — see closed form above
let a22 = (a * a * s * s + b * b * c * c) * inv_ab;
// V̂ = A · (gx, gy)
let vx = a11 * gx + a12 * gy;
let vy = a21 * gx + a22 * gy;
let norm = (vx * vx + vy * vy).sqrt();
if norm < 1e-9 {
return (0, 0);
}
// round(V̂ / ‖V̂‖ · n) → integer vote offset
let scale = n as f32 / norm;
((vx * scale).round() as i32, (vy * scale).round() as i32)
}
The matrix entries a11, a12, a22 implement the closed-form defined above; a21 = a12 follows directly from inspection of the closed form. The final scale division unit-normalises then multiplies by , implementing . The caller uses the returned offset at both and to update and .
Remarks
- Complexity is for a -pixel image. The per- accumulation is , identical to FRS; the grid is the sole additional multiplier. The histopathology nuclei detector uses up to 144 samples ( px, px, for ); with camera-geometry priors available (surveillance, fixed-magnification scanners) the grid collapses toward the FRS 1-D scale space and the runtime multiplier approaches 1.
- Grid coverage is the dominant parameter for detection probability. Degradation as the true moves away from the nearest sampled is smooth, not catastrophic — the nearest-neighbour hypothesis still produces an attenuated, possibly displaced peak — but targets whose parameters fall outside the sampled range are missed silently with no runtime indication.
- The anisotropic Gaussian and the -dependent normalising factor are both required for response calibration across the grid. An isotropic kernel mismatches the anisotropic voting noise; must be recomputed per pair rather than per radius alone, because ellipse perimeter length varies with the semi-axes.
- Failure regime: severe perspective foreshortening or out-of-plane rotation that places the true ellipse parameters outside the sampled grid causes the method to miss detections silently. Fragmented or touching ellipse boundaries (e.g. overlapping nuclei) produce diffuse rather than peaked responses; the method localises ellipse centres but does not segment overlapping structures.
- GFRS is a hypothesis-search detector over a discrete affine grid, not an invariant detector in the SIFT / Harris-Affine sense. Coverage is determined entirely by grid design; there is no analytic guarantee that an arbitrary affine distortion within the bounded-perspective assumption will be covered.
- The per- accumulations are mutually independent and trivially data-parallel; parallelising across the grid reduces wall-clock time proportionally to the number of available cores without any synchronisation overhead.
References
- J. Ni, M. K. Singh, C. Bahlmann. Fast radial symmetry detection under affine transformations. Proc. IEEE CVPR, 2012. ieeexplore.ieee.org/document/6247768
- G. Loy, A. Zelinsky. Fast radial symmetry for detecting points of interest. IEEE TPAMI 25(8)–973, 2003. ieeexplore.ieee.org/document/1217601