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.