Access the pointer of a channel.
The operator get_image_pointer1 returns a pointer to the first channel of the image Image. Additionally, the image type (Type = 'byte', 'int2', 'uint2', etc.) and the image size (width and height) are returned. Consequently, a direct access to the image data in the HALCON database via the pointer is possible from the programming language in which HALCON is used. An image is stored in HALCON linearized in row major order, i.e., line by line.
The pointer returned by get_image_pointer1 may only be used as long as the corresponding image object exists in the HALCON database. This is the case as long as the corresponding variable in the the programming language in which HALCON is used is valid. If this is not observed, unexpected behavior or program crashes may result.
If data is written to an existing image via the pointer, all image objects that reference the image are modified. If, for example, the domain of an image is restricted via reduce_domain, the original image object with the full domain and the image object with the reduced domain share the same image matrix (i.e., get_image_pointer1 returns the same pointer for both images). Consequently, if one of the two images in this example is modified, both image objects are affected. Therefore, if the pointer is used to write image data in the the programming language in which HALCON is used, the image data should be written into an image object that has been created solely for this purpose, e.g., using gen_image1.
|
Image (input_object) |
image -> object : byte / direction / cyclic / int1 / int2 / uint2 / int4 / real / complex / dvf |
| Input image. | |
|
Pointer (output_control) |
pointer -> integer |
| Pointer to the image data in the HALCON database. | |
|
Type (output_control) |
string -> string |
| Type of image. | |
| List of values: 'int1', 'int2', 'uint2', 'int4', 'byte', 'real', 'direction', 'cyclic', 'complex', 'dvf', 'lut' | |
|
Width (output_control) |
extent.x -> integer |
| Width of image. | |
|
Height (output_control) |
extent.y -> integer |
| Height of image. | |
Hobject Bild; char typ[128]; long width,height; unsigned char *ptr; read_image(&Bild,"fabrik"); get_image_pointer1(Bild,(long*)&ptr,typ,&width,&height);
The operator get_image_pointer1 returns the value 2 (H_MSG_TRUE) if exactly one image was passed. The behavior in case of empty input (no input images available) is set via the operator set_system('no_object_result',<Result>). If necessary an exception handling is raised.
get_image_pointer1 is reentrant and processed without parallelization.
set_grayval, get_grayval, get_image_pointer3
Foundation