background_flatten — 3D surface_fit op

• Data kinds: image2d → image2d

• Call: import fullseye as fs; fs.ledger.background_flatten(image, degree=2) (to call the implementation directly, import match3d; match3d.background_flatten(image, degree=2); from the registry, ops3d.get("background_flatten"))

Usage

Fit and subtract a low-order surface (uneven illumination) from an image = shading correction. → flattened.

Fits fit_poly_surface(degree) (default 2nd order) to an (H,W) image with x = column, y = row, and returns image − fit as float64. The output has a mean of almost 0 and contains negative values (for display or thresholding, subtract the min or add a constant). If the foreground is large, the fit is pulled by the foreground too and it gets shaved off (it is safer to fit fit_poly_surface on points excluding the foreground → subtract with eval_poly_surface). Greyscale 2-D only (3-D fails). NaN makes lstsq fail.

Uses: preprocessing before thresholding, illumination correction of ring images unwrapped with polar_unwrap.

Background guides (the physics and conventions behind this op)

• blas_threads_and_memory — Why matrix decompositions are slow — BLAS threads, caches, memory layout

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

Runnable examples (verified samples that actually call this op)

• geometry_metrology — py -3.11 examples_3d/geometry_metrology.py

Ops the type connects to (they accept image2d as input)

fuse_to_voxel · fit_poly_surface · eval_poly_surface · surface_form_error · polar_unwrap · fit_zernike · matcap_shade · antialias

Same category (surface_fit)

fit_poly_surface · eval_poly_surface · surface_form_error


*Provenance: match3d.py — 3D operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.