名稱
gen_image_const - 創建一個灰度值不變的圖像。
用法
gen_image_const( : Image : Type, Width, Height : )
描述
算子gen_image_const創建指定大小的圖像。 圖像的寬度和高度由Width和Height決定。 HALCON支持以下圖像類型:
'byte'
每像素1字節,無符號
取值范圍:(0..255)
'int1'
每個像素1個字節,有符號
取值范圍:(-128..127)
'uint2'
每像素2字節,無符號
Value range: (0..65535)
'int2'
每個像素2個字節,有符號
取值范圍:(-32768..32767)
'int4'
每個像素4個字節,有符號
取值范圍:(-2147483648..2147483647)
'int8'
每個像素8個字節,帶符號(僅適用於64位系統)
取值范圍:(-9223372036854775808..9223372036854775807)
'real'
每像素4個字節,浮點
取值范圍:(-3.4e38..3.4e38)
精度:6位十進制數字
'complex'
兩個類型為'real'的矩陣
'vector_field_relative'
兩個類型為'real'的矩陣
解釋:矢量
'vector_field_absolute'
兩個類型為'real'的矩陣
解釋:絕對坐標
'direction'
每像素1字節,無符號
取值范圍:(0..179)
解釋:角度除以2
注意:值180..254自動設置為255,這被解釋為未定義的角度。
'cyclic'
每像素1字節,無符號循環算術
取值范圍:(0..255)
通過算子set_system('init_new_image',<'true'/'false'>),可以控制創建的圖像是否使用0進行初始化。
並行
● 多線程類型:可重入(與非獨占算子並行運行)。
● 多線程范圍:全局(可以從任何線程調用)。
● 不並行化處理。
參數
Image (output_object) image → object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)
創建的新的圖像矩陣。
Type (input_control) string → (string)
像素類型
Default value: 'byte'
List of values: 'byte', 'complex', 'cyclic', 'direction', 'int1', 'int2', 'int4', 'int8', 'real', 'uint2', 'vector_field_absolute', 'vector_field_relative'
Width (input_control) extent.x → (integer)
圖像寬度。
Default value: 512
Suggested values: 128, 256, 512, 1024
Typical range of values: 1 ≤ Width ≤ 512 (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Width >= 1
Height (input_control) extent.y → (integer)
圖像高度。
Default value: 512
Suggested values: 128, 256, 512, 1024
Typical range of values: 1 ≤ Height ≤ 512 (lin)
Minimum increment: 1
Recommended increment: 10
Restriction: Height >= 1
Example (C)
gen_image_const(&New,"byte",width,height); get_image_pointer1(New,(Hlong*)&pointer,type,&width,&height); for (row=0; row<height-1; row++) { for (col=0; col<width-1; col++) { pointer[row*width+col] = (row + col) % 256; } }
結果
如果參數值正確,則算子gen_image_const返回值2(H_MSG_TRUE)。 否則會引發異常。
Possible Successors
paint_region, reduce_domain, get_image_pointer1, copy_obj
Alternatives
gen_image1, gen_image3
See also
reduce_domain, paint_gray, paint_region, set_grayval, get_image_pointer1
模塊
Foundation
HDevelop例程