align op• Data kinds: image2d × image2d → matrix
• Call: import fullseye as fs; fs.ledger.frame_align(reference, frame, model='similarity', threshold_sigma=5.0, max_stars=60, tolerance_px=2.0, max_shift_px=None, ransac_iters=500, seed=0, min_inliers=3) (to call the implementation directly, import astrostack; astrostack.frame_align(reference, frame, model='similarity', threshold_sigma=5.0, max_stars=60, tolerance_px=2.0, max_shift_px=None, ransac_iters=500, seed=0, min_inliers=3); from the registry, opsastrostack.get("frame_align"))
• Return value through the ledger: fullseye.ledger.frame_align(...) returns **only the declared out type matrix** (the underlying function also returns auxiliary values). When you need what was dropped, use fullseye.ledger.frame_align.raw(...) or call astrostack.frame_align directly.
• Underlying return: (matrix, info) -> matrix
Estimate the 2-D transform `frame → reference` from star correspondences.
> The detailed description below is the original text — the summary and the headings are translated.
工程は 3 段で、推定の本体はどれも既存 op:
1. :func:star_detect で両方の星を取る。
2. 粗い平行移動をオフセット投票で出す(`_vote_translation`)。
ここで :func:features.match_keypoints を使わないのは実測に基づく判断で、
星野の 9x9 パッチは互いにほとんど同じ形なので Lowe の比検定
(既定 ratio=0.8)がほぼ全部を捨てる。128x128 に 40 星、真のずれが
`(+0.590, -0.540) px のフレーム対での実測: match_keypoints` が
返した対応は 4 件、うち真値から 1 px 以内は 0 件(= 使えるものが
1 つも無い)。同じ対で投票法は 26 票 → 26 対応 → 26 内点、推定誤差
0.0155 px。星野は「特徴が無い」のではなく「特徴が全部同じ」なので、
記述子ではなく配置の幾何を使うのが正しい。
3. 粗い移動で最近傍の対応を作り、
:func:mosaic.proj_match_points_ransac で誤対応を落とし、
:func:fit_transform.vector_to_similarity(`model` に応じて
`vector_to_rigid / vector_to_hom_mat2d`)で当てはめる。
RANSAC ループも Umeyama もここには書いていない。
★繰り返し構造には使えない(2026-09-08、poc_print_registration が発見)。
`inlier_ratio` は「同じ答えに賛成した対応の割合」であって「答えが正しい
確率」ではない。網点・織物・格子のように同じ形が周期的に並ぶ画像では、
格子ベクトルぶんずれた対応づけも全員が賛成するので、賛成率は 1.00 のまま
答えだけが格子 1 個ぶん(あるいは何個ぶんも)ずれる。
実測: 256x256 の 133 lpi 相当・15 度の網点を (0.00, +1.30) px だけ
ずらした対で、`inlier_ratio **1.00** / rms_px` 0.78 を返しながら
推定は (+54.24, +30.12) px。星野(128x128、40 星、真値
(+0.59, -0.54))では `inlier_ratio` は同じ 1.00 で推定は正しい。
賛成率では 2 つを区別できない。
区別できるのは `vote_margin` —— 投票の2 番手の山の高さを 1 番手で
割った値で、0 なら山は 1 つ、1 に近いほど「同じくらいもっともらしい答えが
他にもある」。同じ 2 例で 網点 0.857 / 星野 0.143。周期構造を渡す
かもしれない経路では、`inlier_ratio` ではなくこちらを見ること。
平行移動そのものが要るだけなら :func:piv_cross_correlate の相関面を
見るほうが素直で、そちらは山が何本立っているかを自分で数えられる。
*model* `"translation"` は対応の差の中央値だけを使う(星が 1 個でも動く)。
`"rigid" = 回転 + 並進、"similarity"` = + 等方スケール、
`"affine" = 6 自由度。**視野が広くなければ "similarity"` で足りる**
(赤道儀の追尾誤差は回転と並進、大気差はスケールに一次で乗る)。
Returns `(matrix, info)`:
• `matrix —— (3, 3) float64。(row, col, 1)` に左から掛けると
`reference の座標になる(fit_transform` と同じ規約)。
• `info —— dict。n_stars_ref / n_stars_src / n_pairs` /
`n_inliers / inlier_ratio / shift_row / shift_col` /
`rotation_deg / scale / rms_px(内点の残差 RMS)/ model`。
fail-closed: 内点が *min_inliers* に満たなければ `ValueError` を送出
する。恒等変換を黙って返さない —— 位置合わせに失敗したフレームを
「ずれ 0」として合成に混ぜると、例外も警告も無しに二重像ができる。
Raises `ValueError`: 2-D でない / 形が違う / *model* が
:data:ALIGN_MODELS にない / どちらかで星が 1 つも見つからない /
対応が作れない / 内点が足りない場合。
• 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.
• The canonical algorithm (author, year) and its uses are named in the family usage guide above.
• astro_stacking — py -3.11 examples/astro_stacking.py
• poc_exoplanet_transit — py -3.11 examples/poc_exoplanet_transit.py
• poc_print_registration — py -3.11 examples/poc_print_registration.py
matrix as input)—
align)*Provenance: astrostack.py — ASTROSTACK 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.