annotate3d_scale_bar — 3D annotate3d op

• 資料種類:image2d → image2d

• 呼叫: import fullseye as fs; fs.ledger.annotate3d_scale_bar(img, origin, direction, length, pose, K, unit='', depth=None, color='neutral', width=2.0, tick=8.0, font_size=12, label_fmt='{:g}', box_alpha=0.55, text_color=None, occlusion_tol=0.01, scheme='okabe_ito', font_path=None)(要直接呼叫實作,import annotate3d; annotate3d.annotate3d_scale_bar(img, origin, direction, length, pose, K, unit='', depth=None, color='neutral', width=2.0, tick=8.0, font_size=12, label_fmt='{:g}', box_alpha=0.55, text_color=None, occlusion_tol=0.01, scheme='okabe_ito', font_path=None);從台帳取用則 ops3d.get("annotate3d_scale_bar"))

用法

回傳影像(image2d):把網格單位下長度為 length 的比例尺貼在面上並投影。

比例尺是從 origin 沿 direction(正規化)前進 length 的 3-D 線段,投影後的像素長度會隨其相對視線的傾斜而縮短(如實呈現透視與縮短)。若與像平面平行,像素長度為 f * length / z —— tests 會驗證這一點。

Raises

ValueError

direction 為零、length 非正、端點在相機後方 / 影像外。

步驟: 建構 p1 = origin + direction / |direction| * length,投影 origin 與 p1(與 annotate3d_project 相同的慣例)。繪製連接兩端像素的線,以及兩端長度為 tick [px] 的垂直刻度(_bar_with_ticks),在從線的中點朝畫面上方(row 較小的一側)離開 tick/2 + 4 px 的位置放置 label_fmt.format(length) + " " + unit 的文字框。

參數:

• origin (3,)、direction (3,)(只使用方向。忽略長度,零則拒絕),length: 網格單位的長度(> 0,1e-300 以上)。

• unit: 字串(為空則只顯示數值)。label_fmt: str.format 的格式(預設 "{:g}")。

• width [px] >= 0.5、tick [px] >= 0(0 則無刻度)、font_size / box_alpha / text_color / font_path: 文字框的外觀。

• depth: 前方距離影像。若兩端都被遮擋,線畫為虛線。

• color: 預設 "neutral"(角色名)。occlusion_tol: [0, 1)。

回傳值: 繪製後的新影像(float64 [0, 1])。

報錯條件: direction 的範數小於 1e-12 / length <= 0 / 任一端點 z <= 1e-9 / 任一端點在影像外(本 op 要求兩端都 in_image — 與箭頭不同,框外會被拒絕) / 位姿、K、depth 不正確 / 文字框放不下。

注意: 像素上的長度會隨相對視線的傾斜而縮短(與像平面平行時為 f * length / z px)。沿深度方向放置會顯得短,但那才是如實的投影。若要顯示 2 點間的實測值,用 annotate3d_measure。

參考(範例資料、文獻)

• 範例資料目錄(下載 URL / 授權) —— 2-D 用 skimage.data(BSD/公有領域)加合成圖,3-D 給出真實資料源(Stanford/PDS 等)的下載 URL。

• 運算子來歷與參考文獻 —— 該運算子族所依據的研究/方法出處。

可執行的範例(實際呼叫該運算子並已驗證的樣例)

• annotate3d_figure — py -3.11 examples_3d/annotate3d_figure.py

型別可銜接的下一個運算子(可接受 image2d 作為輸入)

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

同類別(annotate3d)

annotate3d_project · annotate3d_arrow · annotate3d_label · annotate3d_axes · annotate3d_bbox · annotate3d_measure


*Provenance: annotate3d.py — 3D 運算子登記表。本條目由 tools/opdocs.py md 自動產生(請勿手動編輯)。*

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