Region Utilities perform standards operations on regions. These include standard arithmetic operations, like multiply and divide, even if the regions have pixels of differing types. For example, it is possible to add an 8-bit region to a floating point region, and store the result into a 16-bit unsigned region.
Headers for these functions are available in Notes
Arithmetic operations are performed "as if" all operands are converted to a new type which has an exact representation for all the values of each type of pixel in the operation.
Before a result is stored back into a pixel, the following conversions are performed: 1) If the result is smaller (larger) than the smallest (largest) value representable in a pixel, it is set to that small (large) value. 2)If any of the operands were a floating point type, and the result is an integer type, the result is rounded down after 0.5 (-0.5) has been added to the positive (negative) value.
Routines which operate on more than one region require all the regions involved to have the same number of rows and columns. If the regUtils routines were compiled with NDEBUG undefined, the dimensions are checked by means of the sh_assert macro. Otherwise, the dimensions are not checked, and calls with mis-sized regions will have unpredictable results. The routines work on sub-regions as well as regions.
Switch the pixel type of the entered region. The type is switched to either the entered type (if allowed) or to the logically correct type. The following switches are allowed.
Regions with pixel types equal to floating point, cannot be switched to any other type.
Return as a double the value of the pixel in REGION at the location specified by ROW and COLUMN. The macro sdss_assert is used to check that ROW and COLUMN are in bounds. See Notes for details about arithmetic operations and region size.
Set the pixel in REGION at ROW, COL to the value implied by CONSTANT. See Notes for details about arithmetic operations and region size.
Set all of the pixels in REGION to the value implied by CONSTANT. See Notes for details about arithmetic operations and region size.
Subtract SUBTRAHEND from MINUEND pixel-by-pixel. Place the resulting pixels in RESULT. RESULT may be the same region as SUBTRAHEND or MINUEND. See Notes for details about arithmetic operations and region size.
Add ADDEND1 to ADDEND2 pixel-by-pixel. Place the resulting pixels in RESULT. RESULT may be the same region as ADDEND1 or ADDEND2. See Notes for details about arithmetic operations and region size.
Add CONSTANT to ADDEND pixel-by-pixel. Place the resulting pixels in RESULT. RESULT may be the same region as ADDEND. See Notes for details about arithmetic operations and region size.
Copy the pixels from REGIN to REGOUT pixel-by-pixel. REGIN and REGOUT may have any type of pixel. This procedure correctly copies regions which overlap. See Notes for details about arithmetic operations and region size.
Compare the pixels in REG1 to REG1 pixel-by-pixel. REGIN and REGOUT may have any type of pixel. If after conversion, a difference is detected, ROWDIFF and COLDIFF are set to the row, col of the difference. See Notes for details about arithmetic operations and region size.
Flip the pixels in REGION row-wise. This procedure may be called on regions having any type of pixel. Flipping is done by copying pixels, not by altering row vectors.
Flip the pixels in REGION column-wise. This procedure may be called on regions having any type of pixel. Flipping is done by copying pixels.
Multiply each pixel in REGIN by CONSTANT. Place the result in REGOUT. REGIN and REGOUT my be the same. See Notes for details about arithmetic operations and region size.
Multiply MULT1 and MULT2 pixel-by-pixel. Divide each pixel by SCALE. Place the result in REGOUT. REGOUT may be the same region as MULT1 or MULT2. See Notes for details about arithmetic operations and region size.
Divide DIVIDEND by DIVISOR pixel-by-pixel. Multiply the intermediate result by SCALE. Place the result in REGOUT. REGOUT may be the same region as DIVIDEND or DIVISOR. See Notes for details about arithmetic operations and region size.