对应示例程序:
measure_tft_cells.hdev
目标:测量TFT液晶显示器中红,绿,蓝三个部分的边缘厚度值
思路为:
1.读取图像,并分成R,G,B三个通道
2.首先根据G通道提取出绿色部分,再将其与R通道做差异,得到包含红色和蓝色部分
3.对包含红色和蓝色的区域进行提取,得到红色部分,再通过区域间的差异性,最终得到蓝色部分
4.利用仿射变换,将图像纠正到垂直方向,方便后续的距离计算,提高测量精度
5.利用measure_pairs提取垂直于测量矩形的直边对,并得到cell厚度
图像:
代码:
dev_close_window ()
dev_update_off ()
Path := 'lcd/tft_cells'
read_image (Image, Path + '_01')
get_image_size (Image, Width, Height)
dev_open_window_fit_size (0, 0, Width, Height, 640, 480, WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
dev_set_color ('green')
dev_set_draw ('margin')
for I := 1 to 7 by 1
read_image (Image, Path + '_' + I$'.2i')
decompose3 (Image, R, G, B)
* First, the cell columns corresponding to each of the three colors (RGB)
* are segmented.
*首先,对三种颜色(RGB)中每种颜色对应的单元格列进行分段。
segment_color_column (G, GreenColumn, GInnerRegions, 200) //分离出绿色 G区域
difference (R, GreenColumn, RegionDifference) //与红色图像做差异
reduce_doma