ARI

Image channel arithmetic


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Related

Back to top

Description


Performs arithmetic operations between two image channels or between an image channel and a scalar constant. Addition, subtraction, multiplication, division, logical AND, and logical OR operations are supported.
Back to top

Parameters


ari(file, oper, cnst, dbic, dboc, zerodiv, autosca, rval, mask, imstat)

Name Type Caption Length Value range
FILE * str Input file name 1 -    
OPER str Operator 0 - 3 ADD, SUB, MUL, DIV, AND, OR
Default: ADD
CNST List[float] Input scalar 0 - 1  
DBIC * List[int] Input channel(s) 1 - 2  
DBOC * List[int] Output channel list 1 - 1  
ZERODIV List[float] Value for division by zero 0 - 1 0.0 -
AUTOSCA str Autoscaling method 0 - 4 ON, OFF, USER
Default: ON
RVAL List[float] Input and output ranges for scaling 0 - 4  
MASK List[int] Area mask (window or bitmap) 0 - 4  
IMSTAT List[float] Image statistics -    

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of PCIDSK file containing image channels.

OPER

Specifies the arithmetic or logical operation to be performed.

Logical operations are performed in a bitwise manner on binary representations of integers by comparing corresponding bit values with corresponding bit values to generate the output pixel value.

The OR option sets a bit value to 1 if one or both of the corresponding bits in its operands have a value of 1, and sets a bit value to 0 if both of the corresponding bits have a value of 0.

The OR option always returns a value of 1, unless the corresponding bit values of both operands are 0.

The AND option sets a bit value to 1 only if both of the corresponding bit values in its operands are 1; it sets a bit value to 0 if the bits differ or if both are 0. A 1 combined with AND with a second bit value is that second bit, and a zero combined with AND with a second bit is zero.

Valid options include:

CNST

Specifies a constant to be applied for the operation.

Acceptable constant values are as follows:
Note:

If the second input channel, DBIC(2), is not specified, the constant must be specified.

If both input channels are specified and the operation is specified to be MUL, DIV, AND, or OR, the constant parameter is ignored.

DBIC

Specifies one or two input image channels. If only one channel is specified, CNST must be specified.

DBOC

Specifies the output image channel to receive the arithmetic or logical results.

ZERODIV

Specifies the value to be used for the result of a division by zero.

AUTOSCA

Specifies the scaling method used to modify the results of the arithmetic operation, to preserve dynamic range. It has no effect on logical operations; that is, if Operation equals "AND" or "OR".

Available values include:
Note:

For more detailed information, see Scaling in the Details section.

RVAL

Specifies the input and output ranges for scaling the results of image arithmetic operations when AUTOSCA="USER".

RVAL is ignored if:

For more detailed information, see Scaling in the Details section.

MASK

Specifies an area in the input channel in which to perform the arithmetic or logical operation.

Examples of valid options include:

IMSTAT

ARI saves the actual range of output values that resulted from the specified arithmetic operation before any scaling was performed in the IMSTAT parameter.

For example:

first  IMSTAT array element : minimum result of operation
second IMSTAT array element : maximum result of operation
Back to top

Details

ARI performs an arithmetic or a logical operation on image data stored in two database image channels (DBIC) and/or a constant (CNST). The result is saved on a specified output channel (DBOC). The output channel can be one of the input channels.

One of the following arithmetic or logical operations can be performed:

For logical operations, real pixel values are truncated to integers, then each bit in the first input channel is correlated to its corresponding bit in the second input channel using AND or OR.

If DBOC(2) is not specified, CNST must be specified; otherwise, ARI exits with an error message.

The MASK parameter specifies the area within the input channel to be processed. Only the area specified under the mask is processed; the rest of the image is unchanged. If a single value is specified, this value points to a bitmap segment that defines the area to be processed. (This is useful, for instance, for enhancing water data while leaving land data unchanged, by using a bitmap to mask all areas of water). When four values are specified, these values define the X and Y offsets and the X and Y dimensions of a rectangular window within the image to be processed. If MASK is defaulted, the entire image is processed.

If an input pixel is NoData, it will be written as NoData in the output. The NoData value of the first input channel will be used to set the NoData value of the output channel.

Scaling

Scaling can be performed for arithmetic operations (ADD, SUB, MUL, or DIV). Scaling is NEVER performed for logical operations (AND or OR).

ARI can perform arithmetic operations on 8-bit unsigned integer, 16-bit signed integer, 16-bit unsigned integer, and 32-bit real channels (layers). These channels have the following ranges for data:

Type				   Min			   Max

8-bit unsigned integer		     0			    255
16-bit signed integer		-32768			  32767
16-bit unsigned integer		     0			  65535
32-bit real			1.0E38			+1.0E38

Because the results of arithmetic operations may be outside of the range of the values that the output channel can store, it is often necessary to scale the results to fit into the output channel. The user can control this scaling using autoscaling, and input and output range specifications.

Three options exist for scaling:
Back to top

Example

Ratios of different spectral bands from the same image are useful in reducing the effects of topography and differential illumination across the scene. The following example performs a simple ratioing of two image channels.

from pci.ari import ari

file="irvine.pix"
oper="DIV"         # specify division operator
cnst=[]            # no constant used in operation
dbic=[1,2]         # channel 1 divided by channel 2
dboc=[8]           # results placed in channel 8
zerodiv=[0]        # divisions by zero forced to zero
autosca="ON"       # automatically scale results
rval=[]            # ignored
mask=[]            # entire image processed
imstat=[]

ari(file,oper,cnst,dbic,dboc,zerodiv,autosca,rval,mask,imstat)
print("Minimum value : ", imstat[0])
print("Maximum value : ", imstat[1])
        

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.