NRAO Home > CASA > CASA Cookbook and User Reference Manual

6.5 Mathematical Operations on an Image (immath)

The inputs are:

#  immath :: Perform math operations on images  
imagename           =         ’’        #  a list of input images  
mode                = ’evalexpr’        #  mode for math operation (evalexpr, spix, pola, poli)  
     expr           =         ’’        #  Mathematical expression using images  
     varnames       =         ’’        #  a list of variable names to use with the image files  
 
outfile             = ’immath_results.im’ #  File where the output is saved  
mask                =         ’’        #  Mask to be applied to the images  
region              =         ’’        #  File path which contains an Image Region  
box                 =         ’’        #  Select one or more box regions in the input images  
chans               =         ’’        #  Select the channel(spectral) range  
stokes              =        ’I’        #  Stokes params to image (I,IV,IQU,IQUV)  
async               =      False        #  If true the taskname must be started using immath(...)

In all cases, outfile must be supplied with the name of the new output file to create.

The mode parameter selects what immath is to do.

The default mode=’evalexpr’ lets the user specify a mathematical operation to carry out on one or more input images. The sub-parameter expr contains the Lattice Expression Language (LEL) string describing the image operations based on the images in the imagename parameter. See § 6.1.3 for more on LEL strings and the expr parameter.

Mask specification is done using the mask parameter. This can optionally contain an on-the-fly mask expression (in LEL) or point to an image with a pixel mask. See § 6.1.4 for more on the use of the mask parameter. See also § 6.1.3 for more on LEL strings. Sometimes, one would like to use a flat image (e.g. a moment image) mask to be applied to an entire cube. The stretch=True subparameter in mask allows one to expand the mask to all planes of the cube.

Region selection is carried out through the region and box parameters. See § 6.1.1 and § 6.1.5 for more on area selection.

Image plane selection is controlled by chans and stokes. See § 6.1.2 for details on plane selection.

For mode=’evalexpr’, the standard usage for specifying images to be used in the LEL expression is to provide them as a list in the imagename parameter, and then access there in the LEL expression by the names IM0, IM1, .... For example,

immath(imagename=[’image1.im’,’image2.im’],expr=’IM0-IM1’,outfile=’ImageDiff.im’)

would subtract the second image given from the first.

For the special modes ’spix’, ’pola’, ’poli’, the required images for the given operation are to be provided in imagename (some times in a particular order). V3.0 ALERT: For mode=’pola’ you MUST call as a function as in the example below (§ 6.5.1.2), giving the parameters as arguments, or immath will fail.

Detailed examples are given below.

  6.5.1 Examples for immath
   6.5.1.1 Simple math
   6.5.1.2 Polarization manipulation
  6.5.2 Using masks in immath


More information about CASA may be found at the CASA web page

Copyright © 2010 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search