gen_image1_extern ( : Image : Type, Width, Height, PixelPointer, ClearProc : )

Create an image from a pointer on the pixels with storage management.

The operator gen_image1_extern creates an image of the size Width * Height. The pixels in PixelPointer are stored line-sequentially. The type of the given pixels (PixelPointer) must correspond to Type. Since the type of the parameter PixelPointer is generic (long) a cast must be used for the call.

The memory for the new image is not newly allocated by HALCON , contrary to gen_image1, and thus is not copied either. This means that the memory space that PixelPointer points to must be released by deleting the object Image. This is done by the procedure ClearProc provided by the caller. This procedure must have the following signature:

void ClearProc(void* ptr);

It is called when deleting Image. If the memory shall not be released (in the case of frame grabbers or static memory) a procedure ``without trunk'' or the NULL-Pointer can be passed. Analogous to the parameter PixelPointer the pointer has to be passed to the procedure by casting it to long.


Parameters

Image (output_object)
image -> object : byte / direction / cyclic / int1 / int2 / uint2 / int4 / real
Created HALCON image.

Type (input_control)
string -> string
Pixel type.
Default value: 'byte'
List of values: 'int1', 'int2', 'uint2', 'int4', 'byte', 'real', 'direction', 'cyclic'

Width (input_control)
extent.x -> integer
Width of image.
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
Height of image.
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

PixelPointer (input_control)
integer -> integer
Pointer to the first gray value.

ClearProc (input_control)
integer -> integer
Pointer to the procedure re-releasing the memory of the image when deleting the object.
Default value: 0


Example (Syntax: C)
void NewImage(Hobject *new)
{
  unsigned char  *image;
  int            r,c;
  image = malloc(640*480);
  for (r=0; r<480; r++)
    for (c=0; c<640; c++)
      image[r*640+c] = c % 255;
  gen_image1_extern(new,"byte",640,480,(long)image,(long)free);
}

Result

The operator gen_image1_extern returns the value 2 (H_MSG_TRUE) if the parameter values are correct. Otherwise an exception handling is raised.


Parallelization Information

gen_image1_extern is reentrant and processed without parallelization.


Alternatives

gen_image1, gen_image_const, get_image_pointer1


See also

reduce_domain, paint_gray, paint_region, set_grayval


Module

Foundation



Copyright © 1996-2008 MVTec Software GmbH