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')