Optical Distortion Lab

A suite of commercial tools for
forward distortion modeling, physical validity control,
parameter estimation, and safe inverse undistortion —
available in MATLAB and Python.

MATLAB Toolbox Python Package NEW Estimation Module NEW Distortion Explorer Contact

What Makes It Different

Three design decisions that distinguish this toolbox from OpenCV, MATLAB's Camera Calibration Toolbox, and standard calibration libraries.

01 — Free Polynomial Model

Arbitrary Degree & Term Count

Polynomial degree and term count are fully user-defined. Odd, even, and mixed-degree terms are all supported. There is no built-in constraint on model complexity.

Standard tools fix the model to odd degrees r³, r⁵, r⁷ — Brown–Conrady only.
02 — Deterministic Inverse

LUT-Based Undistortion, Not Newton–Raphson

The inverse mapping uses a pre-computed lookup table with linear interpolation. Round-trip error is bounded at the interpolation-grid level — no convergence loop, no residual accumulation, no local minima.

Standard tools solve the inverse iteratively — carrying convergence-based residual error on every pixel.
03 — Physical Validity Control

Hard Loss / Soft Loss Monotonicity Analysis

Every distortion model is evaluated for monotonicity before inversion. Non-monotonic regions are reported as hard loss ratio; low-slope regions as soft loss ratio — quantitative metrics not found in standard literature.

Standard tools do not report monotonicity or information loss — folding goes undetected.
04 — Deterministic Calibration

Linear Least-Squares, Not Iterative Optimisation

Parameter estimation is a direct linear system — solved in a single lstsq call. No Levenberg–Marquardt, no gradient descent, no convergence loop. Ignoring interpolation-level noise, the estimated polynomial is exactly correct by construction.

Standard tools minimise a reprojection error iteratively — carrying optimisation residuals and sensitivity to initialisation.

Visual Evidence: Monotonic vs Non-Monotonic Distortion

The same pipeline applied to two models that differ by a single higher-order term — −0.05 · r¹¹. Near the image centre the effect is negligible; toward the outer field it causes a transition from monotonic to non-monotonic radial mapping, resulting in irreversible information loss.

Monotonic Model

Distorted

Monotonic distorted Monotonic

Undistorted

Monotonic undistorted

Radial Mapping

Monotonic radial mapping

Non-Monotonic Model

Distorted

Non-monotonic distorted Non-Monotonic

Undistorted

Non-monotonic undistorted

Radial Mapping

Non-monotonic radial mapping

Distortion & Undistortion Toolbox (MATLAB)

A flexible, high-accuracy framework for modeling, applying, and inverting optical distortion. Built on a forward-first philosophy: distortion is explicitly defined, analyzed, and validated before inverse mapping is applied.

Unlimited Polynomial Models

No predefined limit on polynomial degree or term count. Models are constrained only by mathematics and physical validity.

Deterministic Inverse Mapping

LUT-based inverse — not iterative Newton–Raphson. Round-trip error is bounded at interpolation-grid level, eliminating convergence-based residuals.

Monotonicity & Physical Validity

Automatic detection of non-monotonic mappings, folding, and irreversible information loss before inversion is attempted.

FOV-Adaptive Output Grid

Output canvas size is automatically computed from the distortion model and input field of view.

Custom Sampling Control

Balance accuracy, performance, and output resolution independently of pixel size.

Production Ready

Script-based batch processing, clean user-facing error handling, distributed as .mltbx.


Python Implementation NOW AVAILABLE

The full distortion engine is now available as a standalone Python package. Same forward-first architecture, same physical validity guarantees, same deterministic LUT-based inverse — minimal dependencies, no OpenCV.

Python Distortion Package

Direct port of the MATLAB toolbox for machine learning pipelines, large-scale dataset generation, and research workflows outside MATLAB. Minimal dependencies: NumPy, Pillow, and SciPy only. No OpenCV. No heavy calibration framework.

Commercial · Python

Same Core Engine

Identical polynomial distortion model and LUT-based inverse as the MATLAB version. Results are numerically consistent across both.

Minimal Dependencies

NumPy, Pillow, SciPy — complete dependency list. No OpenCV, no camera calibration framework, no hidden assumptions.

ML & Dataset Ready

Built for large-scale synthetic dataset generation and augmentation pipelines where MATLAB is not available.

Physical Validity Checks

Full hard/soft loss monotonicity analysis included — the same diagnostic framework as the MATLAB toolbox.


Parameter Estimation Module NOW AVAILABLE

Estimates polynomial distortion coefficients from checkerboard calibration images using a fully deterministic pipeline — a direct linear least-squares system, no iterative optimisation. Both estimation and undistortion are deterministic by construction.

Checkerboard-Based Distortion Estimation

Estimation solves A · constants = Δr in a single lstsq call — no iterative optimizer, no convergence risk, no local minima. The result is an explicit, inspectable polynomial model that feeds directly into the distortion engine.

Commercial · MATLAB & Python
Estimation accuracy: ground truth vs estimated distortion function

6-term polynomial with mixed odd and even degrees [2, 3, 5, 6, 9, 11] — a model not expressible in OpenCV or standard calibration tools. Five boards at different FOV positions. The estimated function matches ground truth across the covered radial range; the coefficient table reveals the sub-machine-epsilon recovery.

Deterministic Estimation

A linear system solved once — A[k,m] = r_in[k]^degree[m]. No iterative optimizer, no convergence risk, no local minima.

OpenCV-Free Corner Detection

Harris detection, sub-pixel refinement, and grid sorting implemented from scratch in SciPy — no OpenCV dependency anywhere.

Off-Axis Board Handling

Two-pass algorithm: pass 1 establishes a rough model, pass 2 uses board-centre inversion to refine radial coordinates per board.

Multi-Board Pooling

Multiple boards at different positions pool into a single fit for better radial FOV coverage. Sigma-clipping rejects outlier corners.

Forward-First Design

Estimated constants plug directly into distort() and undistort() — physical validity is checked immediately.

CNN Corner Detection — Coming Soon

EfficientNet-V2-S trained for checkerboard corner detection — replacing Harris detection for robustness on noisy or low-contrast calibration images.


A Different Philosophy

Standard calibration tools — OpenCV, MATLAB's Camera Calibration Toolbox, and similar libraries — are built around a single goal: correct distorted images back to an ideal projection. The forward distortion model is a means to an end, not a first-class object.

This toolbox inverts that priority. The forward model — whether manually specified or estimated from calibration data — is the central object. It is validated for physical correctness first, and inversion is derived from it via LUT, not solved for independently.

Fixed Model Structure

Standard tools fix the polynomial to odd degrees r³, r⁵, r⁷. Even terms, mixed degrees, and higher-order models are not supported — the model complexity is decided for you.

Iterative Everything

Both calibration and inversion rely on iterative numerical methods. Levenberg–Marquardt for estimation, Newton–Raphson for inversion — both carry convergence residuals and sensitivity to initialisation.

No Validity Guarantee

Non-monotonic mappings, folding, and irreversible information loss are not detected. A model that folds at the image edge will produce silently wrong results.

Heavy Dependencies

OpenCV brings a large dependency footprint. The Python implementation here runs on NumPy, Pillow, and SciPy only — no OpenCV anywhere in the pipeline.

The result of a different philosophy: a toolbox where the forward distortion function is explicit, inspectable, physically validated, and inverted without approximation — and where calibration produces an exact answer, not a converged one.


Roadmap & Future Work

CNN Corner Detection

EfficientNet-V2-S integration into the estimation pipeline for more robust performance on noisy or low-contrast calibration images.

Differential Calibration

Physically constrained differential calibration methods for advanced optical systems.

Expanded Estimation Patterns

Line-based and synthetic image pair estimation, extending beyond checkerboard patterns.


Licensing & Availability

Available as a MATLAB toolbox (.mltbx) and a Python package, under commercial licenses for research and industrial use.

Research & Academic License

Suitable for universities, research groups, and individual researchers.

Commercial License

For industrial applications, product development, and internal tooling.

Evaluation Access

Limited evaluation versions available upon request.

Request Licensing Information


Contact & Research Identity

📧 [email protected]

🧪 ORCID: 0009-0008-2682-0572

💼 LinkedIn: Ahmet Başaran

💻 GitHub: HeliumNitrate