surface_residual — 3D freeform op

Data kinds: image2d × image2d × image2d × bspline_surfacemeasurement

Call: import fullseye as fs; fs.ledger.surface_residual(x, y, z, tck) (to call the implementation directly, import bspline_surf; bspline_surf.surface_residual(x, y, z, tck); from the registry, ops3d.get("surface_residual"))

Return value through the ledger: fullseye.ledger.surface_residual(...) returns **only the declared out type measurement** (the underlying function also returns auxiliary values). When you need what was dropped, use fullseye.ledger.surface_residual.raw(...) or call bspline_surf.surface_residual directly.

• Underlying return: {"rms","max","pv"} → pv float

Usage

Return the residual statistics between scattered data and a surface tck (the form error = the deviation from the fit).

> The detailed description below is the original text — the summary and the headings are translated.

各サンプル位置で曲面高さを評価し、観測 z との差の RMS / 最大絶対値 / PV

(peak-to-valley = 最大 - 最小)を計測する。検査ではこれが自由曲面からの

ずれ量(打痕・うねり・欠肉)の定量指標になる。

Returns

-------

dict

`{"rms": float, "max": float, "pv": float}`。max は最大絶対残差、

pv は符号付き残差の最大 - 最小(片側だけの凸/凹も捉える)。

補足:

• 残差の符号は `resid = z - zhat(観測 − 曲面)。正 = 曲面より高い(盛り上がり)、負 = 低い(欠肉)。max は絶対値なので向きは分からず、向きが要るなら eval_bspline_surfacezhat` を取り自分で差を取る。

• x, y, z は任意 shape を受け、内部で `eval_bspline_surface(tck, x, y, grid=False) を通す(tck の種類検査もそこで行われ、曲線 tck や多項式 dict は ValueError`)。z と x の要素数が違うと numpy の形状エラーになる(専用の検査は無く、z が 1 要素だと黙って broadcast される)。

• 単位は z と同じ。`rms は全点の二乗平均平方根なので局所的な打痕は平均で薄まる。局所欠陥は maxpv` で見る。

• 典型: `fit_bspline_surface` → 本 op。フィットに使った点で評価すると smooth が小さいほど残差は 0 に近づく(過適合の指標にもなる)。

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)

bspline_freeformpy -3.11 examples_3d/bspline_freeform.py

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

vol_gaussian_psf · fuse_to_voxel · fresnel_reflectance · snell_angle

Same category (freeform)

fit_bspline_surface · eval_bspline_surface · fit_bspline_curve · eval_bspline_curve


*Provenance: bspline_surf.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.