HGetComp (see figure 5.1) returns the database key of an image component (image matrix, i.e., channel: image_key or domain, i.e., area of definition: region_key) of an image object that is stored under the key obj_key in the HALCON database of iconic objects.
Note that HGetComp automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HGetComp yourself.
int obj_channels; Hkey obj_key; Hkey region_key; Hkey image_key; ... /* get key of object: */ HGetObj(proc_handle,p,o,&obj_key); /* get key of region: */ HGetComp(proc_handle,obj_key,REGION,®ion_key); /* get number of channels: */ HCkP(HPNumOfChannels(proc_handle,p,o,&obj_channels)); for (i=1; i<=obj_channels; i++) { /* get image matrix key: */ HGetComp(proc_handle,obj_key,i,&image_key); /* ...further processing */ }
Figure 5.4: Example for HGetComp: Database keys of all regions and channels within an input image object.
All components of an iconic object are consecutively numbered from 0 to n, with 0 denoting the region (domain) and 1… n denoting the channels (image matrices). To get a better legibility of program code, the constants REGION (= 0), IMAGE_INDEX (= 1), IMAGE1 (= 1), IMAGE2 (= 2), etc. have been defined globally and may be used as parameter values.
Names
HPNumOfChannels
Synopsis
#include "Halcon.h" Herror HPNumOfChannels( Hproc_handle proc_handle, int par_num, INT4_8 obj_num, int *chn_num)
Figure 5.5: Auxiliary routine HPNumOfChannels .
The number of channels per image object obj_num of parameter par_num is accessible via HPNumOfChannels, see figures 5.4 and figure 5.5:
HPNumOfChannels(proc_handle,par_num,obj_num,&obj_channels)
See also HNumOfChannels in section “HNumOfChannels” for a convenience version of this routine when dealing with the first input iconic parameter. More examples of how to use HGetComp can be found in figure 5.6 and figure 5.7.