Skip to content

gen_image1GenImage1GenImage1gen_image1gen_image1🔗

Short description🔗

gen_image1GenImage1GenImage1gen_image1gen_image1 — Create an image from a pointer to the pixels.

Signature🔗

gen_image1( out image Image, string Type, extent.x Width, extent.y Height, pointer PixelPointer )void GenImage1( HObject* Image, const HTuple& Type, const HTuple& Width, const HTuple& Height, const HTuple& PixelPointer )static void HOperatorSet.GenImage1( out HObject image, HTuple type, HTuple width, HTuple height, HTuple pixelPointer )def gen_image1( type: str, width: int, height: int, pixel_pointer: int ) -> HObject

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

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

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

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

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

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

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

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

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

void HImage.GenImage1( string type, int width, int height, IntPtr pixelPointer )

Description🔗

The operator gen_image1GenImage1 creates an image of the size Widthwidthwidth * Heightheightheight. The pixels in PixelPointerpixelPointerpixel_pointer are stored line-sequentially. The type of the given pixels (PixelPointerpixelPointerpixel_pointer) must correspond to Typetypetype (see gen_image_constGenImageConst for a more detailed description of the pixel types). The storage for the new image is newly created by HALCON. Thus, the storage on the PixelPointerpixelPointerpixel_pointer can be released after the call. Note that how to pass a pointer value depends on the used operator signature and programming environment. Make sure to pass the actual memory address where the image data is stored, not the address of a pointer variable. Care must be taken not to truncate 64-bit pointers on 64-bit architectures.

Attention🔗

gen_image1GenImage1 does not check whether the PixelPointerpixelPointerpixel_pointer is valid or not. Thus, it must be ensured by the user that it is valid. Otherwise, the program may crash!

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 / real)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)HImage (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)HObject (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)Hobject * (byte / direction / cyclic / int1 / int2 / uint2 / int4 / real)

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', 'cyclic', 'direction', 'int1', 'int2', 'int4', 'real', 'uint2'"byte", "cyclic", "direction", "int1", "int2", "int4", "real", "uint2"

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

PixelPointerpixelPointerpixel_pointer (input_control) pointer → (integer)HTuple (Hlong)HTuple (IntPtr)intHtuple (Hlong)

Pointer to first gray value.

Example🔗

(C)

void NewImage(Hobject *new)
{
  unsigned char  image[768*525]\;
  int            r,c\;
  for (r=0\; r<525\; r++)
    for (c=0\; c<768\; c++)
      image[r*768+c] = c % 255\;
  gen_image1(new,"byte",768,525,(Hlong)image)\;
}

Result🔗

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

Combinations with other operators🔗

Combinations

Possible predecessors

gen_image_constGenImageConst, get_image_pointer1GetImagePointer1

Alternatives

gen_image3GenImage3, gen_image1_externGenImage1Extern, gen_image_constGenImageConst, get_image_pointer1GetImagePointer1

See also

reduce_domainReduceDomain, paint_grayPaintGray, paint_regionPaintRegion, set_grayvalSetGrayval

Module🔗

Foundation