API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_arithmetic_rect |
This function performs an arithmetic or logical operation on two images, allowing you to specify a rectangular region of the first image on which to perform the operation.
Copy Code
|
|
---|---|
AT_ERRCOUNT ACCUAPI IG_IP_arithmetic_rect( HIGEAR hIGear1, HIGEAR hIGear2, LPAT_RECT lpImageRect2, AT_MODE nOperation ); |
Name | Type | Description |
---|---|---|
hIGear1 | HIGEAR | HIGEAR handle of image 1, which is also the destination image. |
hIGear2 | HIGEAR | HIGEAR handle of image 2. |
lpImageRect2 | LPAT_RECT | Specifies a rectangle in hIGear2, which will be used for processing. Set to NULL for the whole image. |
nOperation | AT_MODE | Specifies the kind of arithmetic operation to perform on the images. See enumIGMergeModes for possible values. |
All pixel formats supported by ImageGear for C and C++.
None
Copy Code
|
|
---|---|
HIGEAR hIGear1; // HIGEAR handle of the first image HIGEAR hIGear2; // HIGEAR handle of the second image AT_DIMENSION nWidth, nHeight; // Dimensions of the first image AT_ERRCOUNT nErrcount; // Count of errs on stack upon ret from func AT_RECT rcRect; // Region to merge // Load image file "picture.bmp" from working directory nErrcount = IG_load_file("picture.bmp", &hIGear1); if(nErrcount == 0) { nErrcount = IG_load_file("picture.tif", &hIGear2); if(nErrcount == 0) { // Get dimensions of the first image and initialize merging region IG_image_dimensions_get(hIGear1, &nWidth, &nHeight, NULL); rcRect.left = 0; rcRect.top = 0; rcRect.right = nWidth / 2; rcRect.bottom = nHeight / 2; nErrcount = IG_IP_arithmetic_rect(hIGear1, hIGear2, &rcRect, IG_ARITH_ADD); // ... // Destroy the second image IG_image_delete(hIGear2); } // Destroy the first image IG_image_delete(hIGear1); } |
This function, like other ImageGear Image Processing and Clipboard API calls, takes an AT_RECT structure as an argument, so that you can merge a rectangular sub-region of hIGear2 into hIGear1. However, before ImageGear performs the operation specified by this function, it will check to see if an internal NRA flag has been set to TRUE, indicating that a mask HIGEAR should be used with the image. If the flag is set to TRUE, and a valid pointer to a mask image has been assigned, ImageGear will override the settings passed to the AT_RECT structure and use the non-rectangular ROI defined by the mask HIGEAR. To create a non-rectangular region of interest, call IG_IP_NR_ROI_to_HIGEAR_mask.
IG_IP_merge is an extended version of IG_IP_arithmetic_rect that allows specifying a rectangular area on the first image to be used for processing, as well as the coordinates in the first image where to place the upper-left corner of the specified rectangle of the second image.