normals_from_depth — 3D range_image op

Data kinds: depthnormalmap

Call: import fullseye as fs; fs.ledger.normals_from_depth(depth, fx=None, fy=None, cx=None, cy=None, orient_to_camera=True, spacing=None) (to call the implementation directly, import range_image; range_image.normals_from_depth(depth, fx=None, fy=None, cx=None, cy=None, orient_to_camera=True, spacing=None); from the registry, ops3d.get("normals_from_depth"))

Usage

Organized depth → oriented unit normals (H,W,3). The cross product of the 3-D points of neighbouring pixels (using the grid structure, O(HW)).

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

fx,fy 指定で透視、未指定で正射。orient_to_camera=True で法線をカメラ(原点)向きに符号統一。

同名の別関数が 1 行ファサードにある。`fullseye.normals_from_depth` は

`(depth, K, smooth=0) の**透視版で K が必須**、こちら(fullseye.ledger`

経由 = `range_image`)は K を取らない正射版。片方の呼び方を覚えると、もう

片方で `TypeError` になる(2026-09-08 実測)。

★`spacing=(dy, dx) は**正射モードでの画素の実寸**。既定 None` は

「1 画素 = 1 単位」で、**異方な格子(例: 列 0.05 mm × 行 0.5 mm)をそのまま

渡すと傾きが黙ってずれる** —— 実測で x 成分が 20 倍(= 1/dx 倍)外れ、例外も

警告も出なかった。実寸が分かっているなら必ず渡すこと。透視モード

(`fx/fy` 指定)では焦点距離が実寸を決めるので無視される。

★`spacing を渡すときは **orient_to_camera=False`** にすること。正射での

「カメラ」は原点(左上・深度 0)という便宜的なもので、実寸を入れると面に対する

その位置が変わり、符号が反転しうる(実測: 傾き 0.1 の平面で

`orient_to_camera=False なら真値 x=-0.0995 と一致、True` では +0.0995)。

向きが要るなら、視線が定義できる座標系で後段で揃える。

法線は隣接画素の外積で出すため両軸に近傍が要る。H<2 or W<2 は第2の接線方向が無く

法線が定義できない(その軸の勾配を 0 とみなすと cross(dPx,0)=[0,0,0] の縮退法線を

静かに返してしまう)。fail-closed で明示的に ValueError 拒否する。

計算は `depth_to_organized_points で 3-D 点 P を作り、np.gradient` の列方向

差分 `dPx と行方向差分 dPy の外積 dPx × dPy` を単位長にする(端は片側差分)。

`orient_to_camera=True では n·(-P) < 0` の画素を反転し、法線が原点(カメラ)を向く

よう揃える。正射モード(`fxfy が None)では P=(u,v,d)` なので原点は画像

左上の深度 0 の位置になり、「カメラ向き」の意味が透視モードと異なる点に注意。`cx`・

`cy` 省略時は画像中心。深度の段差(遮蔽エッジ)をまたぐ画素では外積が段差の向きを

拾って法線が壊れるので、`occlusion_edges` で境界画素を除いてから使う。深度 0 / NaN の

画素は検証せず、法線も不定になる。返り値は float32 の `(H,W,3)`。

Background guides (the physics and conventions behind this op)

blender_interop — Blender との併用 — 形を作って fullseye で測る(軸・単位・正解データの罠)

depth_sensors — 深度センサの知識 — 測距原理・実機の値・欠測の出方

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)

range_imagepy -3.11 examples_3d/range_image.py

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

fuse_to_voxel · render_shaded · phong_shade · matcap_shade · brdf_lommel_seeliger · brdf_hapke · bump_normals_fbm · integrate_normals

Same category (range_image)

depth_to_organized_points · occlusion_edges · bearing_angle_image


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