gen_imag_const 创建灰度图像
gen_image_const(Image,Type,Width,Height)
算子gen_image_const创建指定大小的图像,图像的宽度和高度由Width和Height决定
- Type 像素类型
- 'byte' :每像素1字节,无符号(0-255)
- 'int1' : 每个像素1个字节,有符号(-128~127)
- 'uint2': 每像素2字节,无符号(0~65535)
- 'real': 每像素4字节,浮点(-3.4e38~3.4e38)
- 'complex': 两个类型为'real'的矩阵
- 'cyclic': 每像素1字节,无符号循环算术
- Width & Height 默认值是512
set_grayval 置像素点灰度值
set_grayval(Image,Y,X,Grayval)
- Image 图像
- Y(Row) 输入元组 (坐标y)
- X(Column)输入元组(坐标x)
- 灰度值(Grayval) 要使用的灰度值。默认值是255
代码
* 设定一个单通道照片 大小为120像素 高90像素
gen_image_const (image, 'byte',120,90)
*read_image (Image2, 'F:/Cognex/img picture/15.标定板(A)/2.bmp')
* 设定高度初始位置, 间隔为20像素
for high:=0 to 89 by 20* 设定高度初始位置,间隔为20像素for wide:=0 to 119 by 20* 设定每一格的高度for one_high:=0 to 9 by 1* 设定每一小格的宽度for one_wide:=0 to 9 by 1* 将图片中坐标为(high+one_high,wide+one_wide)的像素点用255(白色)替换set_grayval (image, high+one_high,wide+one_wide, 255)endforendforendfor
endfor
for high:=10 to 89 by 20for wide:=10 to 119 by 20for one_high:=0 to 9 by 1for one_wide:=0 to 9 by 1set_grayval (image, high+one_wide,wide+one_high, 255)endforendforendfor
endfor
write_image (image, 'jpg', 0, '放大版.jpg')