用途:为荧光、明场或电子显微图像添加精确比例尺,用于期刊投稿图与批量图像处理。
主要能力:依据 TIFF XResolution 元数据或用户提供的 --pixels-per-unit 计算比例尺像素长度;支持 TIFF、PNG、JPG、BMP;可配置位置(bottomright、bottomleft、topright、topleft)、--bar-color、--label-color、--bar-thickness;保留原分辨率与元数据;含路径遍历防护,拒绝 ../ 或工作区外绝对路径。
使用方式:需先安装 Pillow(pip install Pillow)。示例:python scripts/main.py --image image.tif --scale 50 --unit um;指定输出与位置:python scripts/main.py --image image.tif --scale 10 --unit um --output annotated.tif --position bottomright;自定义颜色厚度:python scripts/main.py --image image.tif --scale 100 --unit nm --bar-color white --label-color white --bar-thickness 4。必填参数为 --image 与 --scale;--unit 默认 um,可选 um/nm/mm。
限制:仅用于显微图像比例尺标注,细胞分割或非显微图像标注不在范围内。若缺少 XResolution 且未提供 --pixels-per-unit,需先索取校准值,不得编造。文件缺失、位置非法或路径越界会报错退出;执行失败时按回退模板说明阻塞点与部分结果。