text_box — ANNOTATE text op

• 資料種類:image2d × text → image2d

• 呼叫: import fullseye as fs; fs.ledger.text_box(img, text, xy, color='neutral', text_color=None, box_color=None, box_alpha=0.72, anchor='lt', pad=5, font_size=14, min_font_size=9, max_width=None, font_path=None, line_spacing=1.15, scheme='okabe_ito', min_contrast=2.0, border=0, border_color=None, style=None, wrap=True, bold=False, italic=False)(要直接呼叫實作,import annotate; annotate.text_box(img, text, xy, color='neutral', text_color=None, box_color=None, box_alpha=0.72, anchor='lt', pad=5, font_size=14, min_font_size=9, max_width=None, font_path=None, line_spacing=1.15, scheme='okabe_ito', min_contrast=2.0, border=0, border_color=None, style=None, wrap=True, bold=False, italic=False);從台帳取用則 opsannotate.get("text_box"))

用法

帶襯底(半透明板)的文字。溢出不靜默裁切,而是擲出例外。

Parameters

img : ndarray

(H,W) 或 (H,W,C),float [0,1]。

text : str

要繪製的字串。

xy : (x, y)

錨點位置(x=col, y=row,row 向下)。

color : str or sequence

角色名稱或 RGB。未指定 text_color 時,它被當作邊框顏色,

文字則使用易讀的預設顏色。

text_color, box_color : str/sequence or None

文字顏色、底板顏色。None 時為預設(淺色文字 × 深色底板)。文字顏色為 None

時,僅當明亮的預設色相對實際出現在下方的顏色低於 min_contrast

時,才自動切換為深色文字(底板顏色)—— 這是為了讓無底板

(box_alpha=0)放在白底上的刻度、色條、圖例的標籤

不融入白色。明確指定 text_color 時不切換

(顏色是圖的含義,所以不擅自更改,讀不清就拋出例外)。

box_alpha : float

底板的不透明度 [0,1]。0 時不繪製底板(用於刻度標籤)。

anchor : str

'lt','ct','rt','lm','cm','rm','lb','cb','rb' 共 9 種。

pad : int

底板的內側邊距[px]。

max_width : int or None

文字的換行寬度。None 時維持 1 行。

wrap : bool

False 時不換行,維持 1 行並縮小以放進 max_width。

min_contrast : float

文字與「實際出現在其下方的顏色」的對比度下限。低於則

ValueError(與背景同化的文字誰也察覺不到,所以不放行)。

限制(坦白說): 比較的對象是底板下方的平均色,所以

在黑白各半混合的照片上以 box_alpha=0 放置時,平均值

成為中間灰而通過檢查(白色部分上的文字讀不清)。

在底色雜亂的地方,請提高 box_alpha 讓底板發揮作用 ——

這項檢查是為了抓住「忘了底板」,

並不保證「有底板也讀不清」的情況。

border : int

底板邊框線的粗細(0 為無邊框)。顏色為 border_color 或 color。

style : dict or None

原樣傳給繪製邊框線的 imagedraw.draw_polyline 的引數。

Returns

ndarray

相同 shape 的新陣列。

Raises

ValueError

底板超出影像 / 文字放不下 / 對比度不足 /

未知的角色名稱、錨點 / 負的邊距。

詳細使用指南

• figure_annotation 族使用指南

背景知識指南(該運算子背後的物理與規範)

• dataset_conventions — 訓練資料集規範知識 —— COCO / YOLO / VOC 及外觀檢測中的陷阱

參考(範例資料、文獻)

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

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

• 演算法的正典(作者、年份)與用途見上面的族使用指南。

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

• annotate_gallery — py -3.11 examples/annotate_gallery.py

• annotate_paper_tour — py -3.11 examples/annotate_paper_tour.py

• drawlist_deferred — py -3.11 examples/drawlist_deferred.py

• poc_active_contours — py -3.11 examples/poc_active_contours.py

• poc_agv_fleet — py -3.11 examples/poc_agv_fleet.py

• poc_air_hockey_intercept — py -3.11 examples/poc_air_hockey_intercept.py

• poc_ball_bounce — py -3.11 examples/poc_ball_bounce.py

• poc_beam_modal_video — py -3.11 examples/poc_beam_modal_video.py

• poc_cad_scan_deviation — py -3.11 examples/poc_cad_scan_deviation.py

• poc_camera_calibration — py -3.11 examples/poc_camera_calibration.py

• poc_camera_shake_deblur — py -3.11 examples/poc_camera_shake_deblur.py

• poc_connectome_across_worms — py -3.11 examples/poc_connectome_across_worms.py

• poc_crack_width_timeseries — py -3.11 examples/poc_crack_width_timeseries.py

• poc_ct_void_morphology — py -3.11 examples/poc_ct_void_morphology.py

• poc_dehazing — py -3.11 examples/poc_dehazing.py

• poc_dem_terrain — py -3.11 examples/poc_dem_terrain.py

• poc_diabolo_model_and_vision — py -3.11 examples/poc_diabolo_model_and_vision.py

• poc_dic_strain — py -3.11 examples/poc_dic_strain.py

• poc_driving_crossing — py -3.11 examples/poc_driving_crossing.py

• poc_driving_decisions — py -3.11 examples/poc_driving_decisions.py

• poc_driving_endless_map — py -3.11 examples/poc_driving_endless_map.py

• poc_driving_lateral — py -3.11 examples/poc_driving_lateral.py

• poc_driving_longitudinal — py -3.11 examples/poc_driving_longitudinal.py

• poc_driving_pass — py -3.11 examples/poc_driving_pass.py

• poc_driving_school — py -3.11 examples/poc_driving_school.py

• poc_driving_traffic — py -3.11 examples/poc_driving_traffic.py

• poc_driving_weather — py -3.11 examples/poc_driving_weather.py

• poc_emva1288_sensor — py -3.11 examples/poc_emva1288_sensor.py

• poc_eye_to_brain — py -3.11 examples/poc_eye_to_brain.py

• poc_focus_stacking — py -3.11 examples/poc_focus_stacking.py

• poc_food_cutting_measure — py -3.11 examples/poc_food_cutting_measure.py

• poc_granular_heap_repose — py -3.11 examples/poc_granular_heap_repose.py

• poc_graph_hierarchy_segmentation — py -3.11 examples/poc_graph_hierarchy_segmentation.py

• poc_interferometry_step — py -3.11 examples/poc_interferometry_step.py

• poc_kendama — py -3.11 examples/poc_kendama.py

• poc_leak_localization — py -3.11 examples/poc_leak_localization.py

• poc_lidar_terrain_change — py -3.11 examples/poc_lidar_terrain_change.py

• poc_livestock_body_volume — py -3.11 examples/poc_livestock_body_volume.py

• poc_machine_condition_fusion — py -3.11 examples/poc_machine_condition_fusion.py

• poc_malecns_activity_wave — py -3.11 examples/poc_malecns_activity_wave.py

• poc_measurement_system_analysis — py -3.11 examples/poc_measurement_system_analysis.py

• poc_mesh_quality_repair — py -3.11 examples/poc_mesh_quality_repair.py

• poc_motion_magnification — py -3.11 examples/poc_motion_magnification.py

• poc_multibeam_bathymetry — py -3.11 examples/poc_multibeam_bathymetry.py

• poc_panorama_drift — py -3.11 examples/poc_panorama_drift.py

• poc_particle_tracking — py -3.11 examples/poc_particle_tracking.py

• poc_peg_failure_recovery — py -3.11 examples/poc_peg_failure_recovery.py

• poc_peg_insertion_tactile — py -3.11 examples/poc_peg_insertion_tactile.py

• poc_photoelasticity — py -3.11 examples/poc_photoelasticity.py

• poc_powder_scoop_pour — py -3.11 examples/poc_powder_scoop_pour.py

• poc_print_warpage_risk — py -3.11 examples/poc_print_warpage_risk.py

• poc_pxrd_phase_peel — py -3.11 examples/poc_pxrd_phase_peel.py

• poc_registration_basin — py -3.11 examples/poc_registration_basin.py

• poc_river_surface_velocity — py -3.11 examples/poc_river_surface_velocity.py

• poc_rotation_invariance_audit — py -3.11 examples/poc_rotation_invariance_audit.py

• poc_rover_slip_risk_path — py -3.11 examples/poc_rover_slip_risk_path.py

• poc_segmentation_gauntlet — py -3.11 examples/poc_segmentation_gauntlet.py

• poc_stockpile_volume — py -3.11 examples/poc_stockpile_volume.py

• poc_strain_history — py -3.11 examples/poc_strain_history.py

• poc_structure_4d_deterioration — py -3.11 examples/poc_structure_4d_deterioration.py

• poc_superresolution_limits — py -3.11 examples/poc_superresolution_limits.py

• poc_swarm_obstacle_from_flow — py -3.11 examples/poc_swarm_obstacle_from_flow.py

• poc_table_tennis_bounce — py -3.11 examples/poc_table_tennis_bounce.py

• poc_table_tennis_rally_loop — py -3.11 examples/poc_table_tennis_rally_loop.py

• poc_table_tennis_spin — py -3.11 examples/poc_table_tennis_spin.py

• poc_tacscalib_sphere_lut — py -3.11 examples/poc_tacscalib_sphere_lut.py

• poc_template_tracking — py -3.11 examples/poc_template_tracking.py

• poc_timelapse_growth — py -3.11 examples/poc_timelapse_growth.py

• poc_traffic_counting — py -3.11 examples/poc_traffic_counting.py

• poc_ttc_rss — py -3.11 examples/poc_ttc_rss.py

• poc_world_terrain — py -3.11 examples/poc_world_terrain.py

• poc_wound_area_tracking — py -3.11 examples/poc_wound_area_tracking.py

• poc_xyt_event_surface — py -3.11 examples/poc_xyt_event_surface.py

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

arrow · leader_line · label_points · crosshair · legend_box · color_bar · scale_bar · axes_frame

同類別(text)

measure_text


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

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