Mathematics Behind Coffer Illusion: Closed-form Energy Analysis, Perceptual Dominance Inequality and Monte-Carlo Validation
ABSTRACT
The Coffer Illusion is an image that can be seen either as a grid of rectangles or as a set of hidden circles. Despite its popularity, no exact mathematical explanation for this perceptual “flip” has existed. This paper develops the first analytic foundation explaining why rectangles are usually seen first and why circles emerge only later. By decomposing the image into rectangular edge and circular stripe components and computing their responses under Gabor filters (a standard model of early visual neurons), we derive closed-form integrals leading to a provable inequality predicting when local detectors favor rectangles. Extending the analysis with a Hough-transform-inspired global circle-detection model captures later perceptual integration. Monte-Carlo simulations over 200 randomized images reveal four distinct regimes: rectangle-dominant, circle-dominant, both, or neither. These results provide the first quantitative explanation of the Coffer Illusion’s temporal dynamics.
INTRODUCTION.
Visual illusions provide powerful clues about how the human visual system processes information. One striking example is the “Coffer Illusion” created by Anthony Norcia in 2006 [1], in which an arrangement of rectangular tiles can suddenly be perceived as a set of sixteen hidden circles. Although the illusion has been studied informally in the vision science community, there is no existing mathematical theory for why the human brain first detects rectangles and only later detects circles. Most explanations rely on qualitative reasoning about “edge dominance” or “grouping”[2], rather than quantitative models that can be tested mathematically. Understanding the illusion is important because it highlights a fundamental problem in perception: the brain receives ambiguous information and must choose which interpretation to favor. Decades of visual neuroscience show that early stages of the visual system rely on orientation-selective neurons, often modeled by Gabor filters [3], which respond to edges and lines [4]. A Gabor filter is a linear image processing filter that detects image features (such as edges and textures) at a specific orientation, spatial frequency and a scale by combining a sinusoidal wave with a Gaussian envelope. Later stages integrate information over larger regions to detect curves and shapes [5]. However, no prior work has connected these biological ideas to closed-form mathematical predictions about which percept (rectangles or circles) should dominate in the Coffer Illusion. Earlier studies on contour integration and shape perception describe general principles such as “good continuation”, edge grouping, and competition between local and global cues [6, 2]; but none provide explicit equations or inequalities that predict perceptual outcomes for specific images. As a result, the Coffer Illusion has remained an open question: “Can we mathematically predict which shapes the visual system will see first?”
We hypothesize that the early visual system prefers the rectangular interpretation because the Gabor energy (the magnitude of Gabor filter response; representing the strength of detected local features or textures) of the rectangle component exceeds that of the circle component for typical spatial frequencies in the illusion; the circle percept emerges only when global integration accumulates sufficient long-range evidence. This work tests this hypothesis — by decomposing the illusion into two mathematically defined components: a rectangular edge field and a circular stripe field and computing their responses under standard visual receptive-field models. Subsequently it derives closed-form integrals and proves an inequality that predicts when early detectors favor rectangles. Finally, the theory is tested using Monte-Carlo simulations and a global circle-detection model inspired by the Hough transform.
MATERIALS AND METHODS.
All work reported in this paper is computational and mathematical. Full derivations, proofs, and code are provided in the Supplementary Materials.
Image components and parametric models.

The Coffer image, as shown in Fig. 1, is represented as the linear sum:
\[I(x)=A_RR(x)+A_CC(x)\tag{1}\]
where:
\(I(x)\) = image intensity at coordinates \(x=x_1,x_2\ \in\mathbb{R}^2\);
\(R(x)=sgn(x_1)\) = unit-amplitude vertical step edge (half-plane sign function);
\(C(x) \) = unit-amplitude concentric sinusoidal radial grating (circular stripes);
\(A_R\) = amplitude (contrast) of the rectangle/edge component (dimensionless);
\(A_{C\ }\) = amplitude (contrast) of the circular/stripe component (dimensionless).
In analytic derivations we use continuous integrals over \(\mathbb{R}^2\); in numerical simulations these functions are discretized on 2D pixel grids. Example values used in simulations: image size pixels, step located at the image center, circular stripes centered 6 pixels offset from the vertical step to avoid perfect center overlap. In Monte-Carlo trials: stripe wavelength sampled from 6–12 pixel periods, circle radii sampled from 8–40 pixels, \(A_C\) varied uniformly in \([0,1.6]\), and \(A_R=1\) fixed for thresholding and visualization.
Gabor filter model and orientation tuning.
Early visual filtering is modeled by real-valued Gabor kernels with a bank of orientations . The unnormalized Gabor used in analytic work is:
\[\widetilde{G}(x_1,x_2)=\exp{\left(-\frac{x_1^2}{2\sigma_x^2}-\frac{x_2^2}{2\sigma_y^2}\right)}\cos{(}kx_1), \quad k=2\pi f\tag{2}\]
where:
\(\sigma_x,\sigma_y\) = Gaussian envelope widths in \(x_1\) and \(x_2\) directions (pixels);
\(f\) = spatial frequency (cycles per pixel);
\(k\) = angular spatial frequency (radians per pixel).
Filters are normalized in \(L^2\) so that \(||G||_2=1\) when used for inner products. Typical kernel parameters used in numerical checks: \(\sigma_x=\sigma_y=4\) pixels, wavelength = 8 pixels \((f=1/8)\), with kernel sizes of 31 or 41 pixels for discrete summation. Orientation tuning of populations is summarized by a Gaussian angular tuning of standard deviation \(\sigma_\theta\) (we used \(\sigma_\theta\approx0.35\) rad in analytic estimates). Modeling oriented, band-pass receptive fields as Gabors follows standard practice in visual neuroscience [6, 3].
Closed-form integrals and geometric constants.
The closed-form expressions for the unnormalized inner products \(N_R=\langle R_{unit},\widetilde{G}\rangle\) and \(N_C=\langle S_0,\widetilde{G}\rangle\) (where \(S_0\) denotes a locally aligned cosine stripe), as well as the normalization factor \(Z=||\widetilde{G}||_2\), are derived in Supplementary Materials. These integrals reduce to standard Gaussian × cosine Fourier integrals. The final normalized geometric constants are:
\[\alpha_R=\frac{N_R}{Z},\ \ \ \ \alpha_C=\frac{N_C}{Z}\tag{3}\]
The explicit closed-form formulas for \(\alpha_R\) and \(\alpha_C\) are given in the Results section (Eq. 4–5). The orientation-dilution factor is:
\[F(\Delta\theta,\sigma_\theta)=\frac{\sqrt{2\pi}\ \sigma_\theta}{\Delta\theta}erf\left(\frac{\Delta\theta}{2\sqrt2\ \sigma_\theta}\right)\tag{4}\]
where:
\(Δθ≈κw\) = local orientation spread (from curvature \(κ\) and filter support \(w\));
\(\sigma_\theta\) = orientation tuning width (radians);
\(erf \) = error function.
Discrete numerical verification.
To verify the closed-form results, we constructed discrete sampled Gabors on finite grids and computed direct inner products (discrete sums) with discretized step and stripe patterns. Kernels were centered on the grid, tiled to the local window, and normalized by their discrete \({L}^2\) norm to match the continuous normalization. We report both closed-form continuous values and discrete sums, and we note sampling/centering artifacts (e.g., exact cancellation of a symmetric step on a perfectly centered discrete grid). To address this we also computed shifted versions and verified agreement to numerical precision. Numerical checks used kernel sizes of 31 or 41 and the same parameter values used in analytic examples.
Local readout and energy measure.
Local detector outputs are computed as signed filter responses:
\[r_{\theta,x_0}[I] = \langle I,G_{\theta,x_0}\rangle, \ \ \ E_{\theta,x_0}[I] = r_{\theta,x_0}[I]^2 \tag{5}\]
The local early readout uses the maximum orientation energy \(E_{\max{,}x_0}=\underset{\theta}{max}\ {E_{\theta,x_0}}\) at the analysis center. We compare per-component maxima \(E_R\) vs \(E_C\) (component-specific responses computed by projecting \(R\) and \(C\) separately) to evaluate the derived perceptual dominance inequality (Theorem 1 in Supplementary).
Global accumulator (Hough-style) implementation.
To model later perceptual integration we implement a circular accumulator inspired by the classical Hough transform:
\[H\left(a,b,r\right)={\iint_{\Omega}\mathbf{1}}_{edge}(x,y)\cdot\mathbf{1}\left\{\left|\sqrt{(x-a)^2+(y-b)^2}-r\right|<\epsilon\right\}\ dx\ dy\tag{6}\]
where:
\(H(a,b,r)\) = accumulator value for circle center \((a,b)\) and radius \(r\);
\(\mathbf{1}_{edge}(x,y)\) = indicator function for edge pixels (1 if edge, 0 otherwise);
\(\epsilon\) = small tolerance for radius matching;
\(\Omega\) = image domain.
Edge evidence is derived from the radial grating component by computing the gradient magnitude and thresholding the top quantile (top 10%) to form a sparse set of edge points. For each edge sample we cast votes into candidate circle centers at offsets corresponding to integer points on a circle of radius . The accumulator value at the true circle center (known from synthetic image generation) is used to assess whether global evidence exceeds background fluctuations. Detection is declared when the center vote exceeds the accumulator mean plus three standard deviations and an absolute vote minimum (set to 2 votes).
Monte-Carlo simulation protocol.
We ran 200 randomized trials with independent draws of \(A_C\), stripe wavelength, and circle radius (ranges specified above). For each trial, firstly compute per-orientation center responses for rectangle and stripe components across a Gabor bank of 12 orientations \((θ=0,π/12,2π/12,…,11π/12)\). Then classify local preference by comparing \(R_{max}\) and \(C_{max}\) (squared responses). After that, compute global detection using the accumulator threshold test (mean + 3 standard deviations). Finally, bin outcomes into four categories: local only (rectangle dominant, no circle detected), global only (circle detected, no rectangle dominant), both (rectangle dominant and circle detected), neither (insufficient evidence for either). (See Table 1)
Phase diagram and parameter sweeps.
Using the closed-form ratio \(\alpha_C/\alpha_R\) and the analytic orientation dilution factor \(F\) (Eq. 4), we produced 1D and 2D (Supplementary, Figs. S1-S3) phase diagrams showing the predicted ratio as a function of the dimensionless product \(k\sigma_x\) and envelope anisotropy \({\ \sigma}_x/\sigma_y\). Paramete grids used resolution for smooth color maps; these analytic plots require only direct evaluation of algebraic formulae and no numerical convolution.
Software, numerical libraries, and reproducibility.
All numerical experiments and figures were produced using Python (standard scientific stack). Primary libraries used: NumPy for array operations and numerical sums, Matplotlib for plotting, and the Fast Fourier Transform (FFT)-based convolution where needed. The analytic derivations were verified by comparing closed-form evaluations to discrete sums. All codes are included in the Supplementary Materials. Parameter choices used to generate each figure are listed in the respective figure captions. The analyses were performed on standard desktop hardware; no proprietary software or external datasets were used. Modeling orientation-selective receptive fields with Gabor kernels follows established practice in visual neuroscience [3]. The Hough-style accumulator implemented for circle detection (Supplementary, Fig. S6) follows classical accumulator methods for global shape detection.
RESULTS.
All detailed derivations, proofs of theorems, numerical verifications, and phase diagrams are provided in the Supplementary Materials. Below we present only the core empirical validation.
Closed-form geometric constants and dominance threshold.
From Gaussian-Gabor integrals (Supplementary, Eqs. S1–S5), we derived the geometric constants \(\alpha_R\) and \(\alpha_C\). The ratio \(\alpha_C/\alpha_R\) depends primarily on \(k\sigma_x\); envelope anisotropy has negligible effect (Supplementary, Fig. S3). The orientation-dilution factor is \(F(\Delta\theta,\sigma_\theta)=\frac{\sqrt{2\pi}\ \sigma_\theta}{\Delta\theta}erf\left(\frac{\Delta\theta}{2\sqrt2\ \sigma_\theta}\right)\) (Supplementary, Eq. S6). The dominance threshold is given by \(\beta=(\alpha_C/\alpha_R)F\). For our canonical parameters (\(\sigma_x=\sigma_y =\ 4\ px\), wavelength \(=\ 8\ px\), radius \(\approx\ 60\ px\)), \(β\ \approx\ 4.996\), predicting that local detectors favor rectangles when \(A_C<0.200\) (with \(A_R=1\) ) (Fig. 2 & Supp. Fig. S5).

Monte-Carlo validation.
We executed 200 randomized trials with fixed, , circle radius pixels, and stripe wavelength pixels. Outcomes (Supplementary, Fig. S4 & Tab. S1):
| Table 1. Classification outcomes from a 200-trial Monte-Carlo simulation. The table summarizes the counts and percentages of trials classified based on the presence of local orientation evidence (rectangle dominance) and global accumulator evidence (circle detection). | |||
| Serial | Category | Count (out of 200) | Percentage |
| 1 | Local Only (Rectangle dominant, no circle detected) | 70 | 35.0% |
| 2 | Global Only (No rectangle dominant, circle detected) | 20 | 10.0% |
| 3 | Both (Rectangle dominant and circle detected) | 17 | 8.5% |
| 4 | Neither (Insufficient local or global evidence) | 93 | 46.5% |
| Total | 200 | 100.0% | |
The Monte-Carlo results empirically validate the theoretical picture: an intermediate regime exists where local per-orientation energy favors rectangles (per the analytic threshold) while a slow global accumulator still gathers sufficient coherent votes to detect the circles (the “both” category). Many trials with small are local-only; many weak or highly noisy configurations produce neither detection (Fig. 3).

DISCUSSION.
Our results directly support the hypothesis that the Coffer Illusion is initially perceived as geometric shapes because early orientation-selective detectors (modeled by Gabor filters) produce larger local energy for the rectangular component than for the circular stripe component; circles appear later because a slow global integrator (Hough-style accumulator) accumulates coherent evidence across positions and orientations. The central novel finding is that the ratio \(\alpha_C/\alpha_R\) collapses onto a single dimensionless quantity \(k\sigma_x\) (spatial frequency × filter width), while envelope anisotropy \(\sigma_x/\sigma_y\) has negligible effect, explaining why the illusion is robust across variations in receptive-field shape. The proved inequality \(A_R>A_C\cdot\beta\) (where \(\beta=(\alpha_C/\alpha_R)F\)) predicts exactly when local detectors favor rectangles. Monte-Carlo simulations confirm four regimes: local-only (rectangle), global-only (circle), both (rectangle-first, circle-later), and neither. The “neither” outcomes (46.5%) arise from our strict accumulator threshold (mean + 3σ); biological systems likely use lower thresholds, converting many such cases to “both” or “local-only.” Our model has limitations: it abstracts away multi-scale filtering, divisive normalization, and attention, capturing early V1 processing but not later cortical mechanisms. Future directions include psychophysical validation testing the predicted threshold \({\ A}_C/A_R\) across controlled variations in stripe contrast, spatial frequency, and curvature, as well as extension to multi-scale filter banks and divisive normalization. In sum, this work provides the first quantitative, mathematical explanation of the Coffer Illusion, establishing a baseline theory that can be extended empirically.
ACKNOWLEDGMENTS.
I would like to thank the reviewers and the editor for their valuable insights on an earlier version of this manuscript.
SUPPORTING INFORMATION.
Detailed mathematical derivations are provided in the Supplementary Materials. All Python codes for generating figures, performing Monte-Carlo simulations, and computing closed-form constants is available at https://github.com/MRSA1/coffer-illusion-mathematics. The repository includes complete source code, documentation and all generated figures.
REFERENCES.
- Norcia, A., 2006. The Best Illusion of the Year Contest, Neural Correlate Society, https://illusionoftheyear.com/files/norcia/submission1/CofferIllusion.pdf
- S. E. Palmer, “Vision Science: Photons to Phenomenology” (MIT Press, Cambridge, MA, 1999).
- J. G. Daugman, Uncertainty relation for resolution in space, spatial frequency, and orientation optimized by two-dimensional visual cortical filters. J. Opt. Soc. Am. A 2, 1160–1169 (1985).
- D. H. Hubel, T. N. Wiesel, Receptive fields, binocular interaction and functional architecture in the cat’s visual cortex. J. Physiol. 160, 106–154 (1962).
- Loffler, G. Perception of contours and shapes: Low and intermediate stage mechanisms. Vision Res. 48 (20), 2106–2127 (2008)
- D. J. Field, A. Hayes, R. F. Hess, Contour integration by the human visual system: Evidence for a local association field. Vision Res. 33, 173–193 (1993).
Posted by buchanle on Wednesday, July 29, 2026 in May 2026.
Tags: Coffer Illusion, Gabor-filter, Hough transform
