5.4.4   HPutImage

HPutImage (see figure 5.19) stores the gray value channel (image matrix) image in the database of iconic objects and returns the corresponding database key in the parameter obj_key. This key can be used to insert the gray value channel (now encapsulated in a database object) as a component of an arbitrary number of image objects (see HDefObj in section “HDefObj”). The parameter copy (false or true) specifies, whether the pixel data is copied to the HALCON database14) or only the address of the data is passed to the database object. Figure 5.21 shows a typical example for how to use HPutImage.

Note that HPutImage automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HPutImage yourself.

    Himage    image;
    Hrlregion *region;
    Hkey      image_key,obj_key;
    ...
    /* processed image data:  image  */
    /* processed region data: region */
    par_num = 1;
    HPutImage(proc_handle,&image,true,&image_key);
    HCrObj(proc_handle,par_num,&obj_key);
    HDefObj(proc_handle,obj_key,image_key,IMAGE_INDEX);
    HPutDRL(proc_handle,obj_key,region,&region_key);

Figure 5.21: Creating a new image object using basic Extension Package Interface routines.

14) This is necessary if the original data is stored in temporary memory or if the data will be modified later on.