| Environments | PYTHON :: EASI :: MODELER |
| Quick links | Description :: Parameters :: Parameter descriptions :: Details :: Example :: Related |
| Back to top |
| Back to top |
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 | - |
| Back to top |
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.
CNST
Specifies a constant to be applied for the operation.
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".
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".
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.
Unspecified: no mask area is specified; processes the entire channel.
For example:
MASK =
Window: mask area specified using X and Y offset and X and Y size coordinates; processes the area under the defined rectangular window.
For example:
MASK = xoff,yoff,xsize,ysize
Bitmap: mask area specified by a bitmap on an input segment; processes the area under the specified bitmap.
For example:
MASK = b
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 |
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.
If autoscaling is OFF, no scaling is performed. If the resulting value is less than the output channel can hold, it will be set to the smallest value that the output channel can hold. If the resulting value is greater than the output channel can hold, it will be set to the greatest value that the output channel can hold. This option is most commonly used if the output channel is Real.
If autoscaling is ON, automatic scaling is performed. This is accomplished by performing two passes on the data. The first pass is used to determine the minimum and maximum values resulting from the arithmetic operation. In the second pass, these values are used to scale the results to the full range of the output channel.
If autoscaling is USER, scaling is determined by the specified input and output ranges. Result values between the minimum and maximum input values are linearly scaled to fit within the range of minimum and maximum output values. Result values less than the minimum input value are set to the minimum output values; values greater than the maximum input value are set to the maximum output value.
You MUST specify the minimum and maximum input values. The minimum and maximum output values can be defaulted. For 8-bit or 16-bit output channels, the defaults are the minimum and maximum range for the channel. For Real output channels, the minimum output value defaults to the minimum input value, and the maximum output value defaults to the the maximum input value.
| Back to top |
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.