处理显微镜图片时,有时候会需要在图片下方添加信息栏,标注图片的名字,比例尺,放大倍率等。
可将信息栏生成为一张与原图等宽的图片高度为原图10%的图片,在上面显示文字,使用dump_window_image截取信息栏图像。
使用图片拼接的方式将原图和信息栏拼接在一起。可使用算子tile_images_offset拼接图片。
- read_image (Image0, 'Test.png')
- Filename:='Test'
- Scale:=100
- Resolution:=0.175
- RulerInUm:=20
- *生成信息栏
- get_image_size (Image0, Width, Height)
- gen_image_const (NullImage, 'byte', Width, Height/10.0)
- get_image_size (NullImage, Width2, Height2)
- paint_region (NullImage, NullImage, NullImage, 255, 'fill')
- *生成比例尺
- gen_rectangle2 (Rectangle,Height2/2.0, Width2/2.0, 0, RulerInUm/Resolution, Height2/50.0)
- paint_region (Rectangle, NullImage, NullImage, 0, 'fill')
- *显示文本
- dev_open_window (0, 0, Width2, Height2, 'black', WindowHandle)
- dev_set_part (0, 0, Height2-1, Width2-1)
- dev_display (NullImage)
- FontSize:=Height2/4.0
- set_display_font (WindowHandle, FontSize, 'mono', 'true', 'false')
- set_tposition (WindowHandle, 0, 0)
- dev_disp_text (Filename, 'window', 'center', 'left', 'black', 'box', 'false')
- dev_disp_text (Scale+'x', 'window', 'center', 'right', 'black', 'box', 'false')
- dev_disp_text (RulerInUm+' um', 'window', 'top', 'center', 'black', 'box', 'false')
- *截取文字图像
- dump_window_image (DumpImage, WindowHandle)
- rgb1_to_gray (DumpImage, GrayImage)
- dev_close_window ()
- *把信息栏加进去
- concat_obj (Image0, GrayImage, imgs)
- tile_images_offset (imgs, TiledImage, [0, Height], [0,0], [-1,-1], [-1,-1], [-1,-1], [-1,-1], Width, Height *1.1)
- dev_display (TiledImage)
复制代码 |