NRAO Home > CASA > CASA Toolkit Reference Manual
##### image.set - Function

1.1.1 Set pixel and/or mask values with a scalar in a region-of-interest of the image

Description

This function replaces data and/or mask values within the image in the specified region-of-interest. You can think of it as a simplified version of the image calculator.

Unlike the calc function, you can only set a scalar value for all pixels in the specified region-of-interest. For example, it can be useful to set a whole image to one value, or a mask in a region-of-interest to one value. Although you could do that with the related functions putregion and putchunk, you would have to make an array of the shape of the image and if that is large, it could be resource expensive.

The value for the pixels is specified with the pixels argument. It can be given as either a Lattice Expression Language (or LEL) expression string or a simple numeric scalar. See note 223 for a detailed description of the LEL expression syntax. If you give a LEL expression it must be a scalar expression.

Note that any default mask is ignored by this function when you set pixel values. This is different from calc where the extant mask is honoured.

The value for the pixel mask is specified with the pixelmask argument (T, F, unset). If it’s unset then the mask is not changed.

Arguments

 Inputs pixels The pixel value, LEL scalar expression or numeric scalar. Default is unset. allowed: variant Default: pixelmask The pixel mask value. Either 0 or 1 if set. Default is unset. allowed: int Default: -1 region Region selection. See ”help par.region” for details. Default is to use the full image. allowed: any Default: variant list List the bounding box and any mask creation to the logger allowed: bool Default: false
Returns
bool

Example

"""
#
print "\t----\t set Ex 1 \t----"
ia.maketestimage(’yy’,overwrite=true)
ia.fromshape(’xx’, [10,20], overwrite=true)
r1 = rg.box([2,2],[6,8])         # Make a box region
ia.set(pixels=1.0)               # Set all pixels to 1
ia.set(pixels=’2.0’, region=r1)  # Set all pixels to 2 in the region
ia.set(pixels=’min(yy)’)         # Set all pixels to minimum of image yy
# Set pixels in region to minimum of image xx
ia.set(pixels=’min(’+ia.name(strippath=T)+’)’, region=r1)
ia.close()
#
"""

__________________________________________________________________