一杯清酒邀明月
天下本无事,庸人扰之而烦耳。

名称

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)

1 gen_image_const(&New,"byte",width,height);
2 get_image_pointer1(New,(Hlong*)&pointer,type,&width,&height);
3 for (row=0; row<height-1; row++)
4 {
5   for (col=0; col<width-1; col++)
6   {
7     pointer[row*width+col] = (row + col) % 256;
8   }
9 }

结果

如果参数值正确,则算子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例程

 

posted on 2021-02-23 13:47  一杯清酒邀明月  阅读(760)  评论(0编辑  收藏  举报