Skip to content

gen_image_constGenImageConstGenImageConstgen_image_constgen_image_const🔗

Short description🔗

gen_image_constGenImageConstGenImageConstgen_image_constgen_image_const — Create an image with constant gray value.

Signature🔗

gen_image_const( out image Image, string Type, extent.x Width, extent.y Height )void GenImageConst( HObject* Image, const HTuple& Type, const HTuple& Width, const HTuple& Height )static void HOperatorSet.GenImageConst( out HObject image, HTuple type, HTuple width, HTuple height )def gen_image_const( type: str, width: int, height: int ) -> HObject

Herror gen_image_const( Hobject* Image, const char* Type, const Hlong Width, const Hlong Height )

Herror T_gen_image_const( Hobject* Image, const Htuple Type, const Htuple Width, const Htuple Height )

void HImage::HImage( const HString& Type, Hlong Width, Hlong Height )

void HImage::HImage( const char* Type, Hlong Width, Hlong Height )

void HImage::HImage( const wchar_t* Type, Hlong Width, Hlong Height ) (Windows only)

public HImage( string type, int width, int height )

void HImage::GenImageConst( const HString& Type, Hlong Width, Hlong Height )

void HImage::GenImageConst( const char* Type, Hlong Width, Hlong Height )

void HImage::GenImageConst( const wchar_t* Type, Hlong Width, Hlong Height ) (Windows only)

void HImage.GenImageConst( string type, int width, int height )

Description🔗

The operator gen_image_constGenImageConst creates an image of the indicated size. The width and height of the image are determined by Widthwidthwidth and Heightheightheight. HALCON supports the following image types:

  • 'byte'"byte" 1 byte per pixel, unsigned

    Value range: (0..255)

  • 'int1'"int1" 1 byte per pixel, signed

    Value range: (-128..127)

  • 'uint2'"uint2" 2 bytes per pixel, unsigned

    Value range: (0..65535)

  • 'int2'"int2" 2 bytes per pixel, signed

    Value range: (-32768..32767)

  • 'int4'"int4" 4 bytes per pixel, signed

    Value range: (-2147483648..2147483647)

  • 'int8'"int8" 8 bytes per pixel, signed (only available on 64 bit systems)

    Value range: (-9223372036854775808..9223372036854775807)

  • 'real'"real" 4 bytes per pixel, floating point

    Precision: 6 significant decimal digits

    Value range: (-3.4e38..3.4e38)

  • 'complex'"complex" Two matrices of type 'real'"real"

  • 'vector_field_relative'"vector_field_relative" Two matrices of type 'real'"real"

    Interpretation: Vectors

  • 'vector_field_absolute'"vector_field_absolute" Two matrices of type 'real'"real"

    Interpretation: Absolute coordinates

  • 'direction'"direction" 1 byte per pixel, unsigned

    Interpretation: Angle divided by two

    Value range: (0..179)

    Attention: The values 180..254 are automatically set to the value 255, which is interpreted as undefined angle.

  • 'cyclic'"cyclic" 1 byte per pixel, unsigned, cyclic arithmetics

    Value range: (0..255)

With the operator set_system('init_new_image',<'true'/'false'>), it can be controlled whether the created image is initialized with 0 or not.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Imageimageimage (output_object) image → object (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)HImage (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)Hobject * (byte / direction / cyclic / int1 / int2 / uint2 / int4 / int8 / real / complex / vector_field)

Created image with new image matrix.

Typetypetype (input_control) string → (string)HTuple (HString)HTuple (string)strHtuple (char*)

Pixel type.

Default: 'byte'"byte"
List of values: 'byte', 'complex', 'cyclic', 'direction', 'int1', 'int2', 'int4', 'int8', 'real', 'uint2', 'vector_field_absolute', 'vector_field_relative'"byte", "complex", "cyclic", "direction", "int1", "int2", "int4", "int8", "real", "uint2", "vector_field_absolute", "vector_field_relative"

Widthwidthwidth (input_control) extent.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Width of image.

Default: 512512
Suggested values: 128, 256, 512, 1024128, 256, 512, 1024
Value range: 1 ≤ Width (lin)
Minimum increment: 1
Recommended increment: 10

Heightheightheight (input_control) extent.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Height of image.

Default: 512512
Suggested values: 128, 256, 512, 1024128, 256, 512, 1024
Value range: 1 ≤ Height (lin)
Minimum increment: 1
Recommended increment: 10

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\;
  }
}

Result🔗

If the parameter values are correct, the operator gen_image_constGenImageConst returns the value 2 (H_MSG_TRUE). Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible successors

paint_regionPaintRegion, reduce_domainReduceDomain, get_image_pointer1GetImagePointer1, copy_objCopyObj

Alternatives

gen_image1GenImage1, gen_image3GenImage3

See also

reduce_domainReduceDomain, paint_grayPaintGray, paint_regionPaintRegion, set_grayvalSetGrayval, get_image_pointer1GetImagePointer1

Module🔗

Foundation