nraonrao
 
 NRAO Home > CASA > CasaDocument
image.replacemaskedpixels - Function

1.1.1 replace the values of pixels which are masked bad
Description

This function replaces the values of all pixels whose total input mask (default input pixel mask and OTF mask) is bad (F) with the specified value.

If the argument update is F (the default), the actual pixel mask is left unchanged. That is, masked pixels remain masked. However, if you set update=T then the pixel mask will be updated so that the pixel mask will now be T (good) where the total input mask was F (bad).

See maskhandler for information on how to set the default pixel mask.

There are a few ways in which you can specify what to replace the masked pixel values by.

Arguments





Inputs

pixels

The new value(s), Numeric scalar or LEL expression

allowed:

any

Default:

variant

region

The region of interest. Default is whole image.

allowed:

any

Default:

record

mask

OTF mask, Boolean LEL expression or mask region. Default is none.

allowed:

any

Default:

variant

update

Update mask as well?

allowed:

bool

Default:

false

list

List the bounding box to the logger

allowed:

bool

Default:

false

Returns
bool

Example

"""  
#  
print "\t----\t replacemaskedpixels Ex 1 \t----"  
ia.maketestimage(’zz1’,overwrite=true)  
ia.calcmask(’zz1<0’)  
ia.replacemaskedpixels(0.0)  
ia.replacemaskedpixels(’min(zz1)’)  
ia.close()  
#  
"""

These examples replace all masked pixels by the specified scalar. In the second case, the scalar comes from a LEL expression operating on zz1 (or it could be from an LEL expression operating on some other image).

Example

"""  
#  
print "\t----\t replacemaskedpixels Ex 2 \t----"  
ia.maketestimage(’zz2’,overwrite=true)  
ia.close()  
ia.maketestimage(’zz1’,overwrite=true)  
#ia.calcmask(’zz1<0’)  
ia.replacemaskedpixels(0.0, mask=’zz2>0’)  
ia.close()  
#  
"""

Let us say that zz1 has no mask. By using the mask argument, we generate a transient mask which is T (good) when the pixel values are positive. This means that all non-positive values (when that mask is F [bad]) will be replaced with the value 0. If zz1 did have a mask it would be applied as well as the transient mask (the masks would be logically ORed).

Example

"""  
#  
print "\t----\t replacemaskedpixels Ex 3 \t----"  
ia.maketestimage(’zz1’,overwrite=true)  
ia.calcmask(’zz1<0’)  
im2 = ia.subimage(outfile=’zz2’,overwrite=true)  
# r = rg.quarter()  
r=ia.setboxregion([0.25,0.25],[0.75,0.75],frac=true)  
ia.replacemaskedpixels(0.0, region=r, mask=im2.name(strippath=T)+’>0’)  
# same as ia.replacemaskedpixels(0.0, region=r, mask=’zz2>0’)  
im2.done()  
ia.close()  
#  
"""

The specified region takes one quarter of the image by area centered on the image center. The region is applied to the mask expression as well - this means that any images in the mask expression must conform with the zz1 image. The replacement of the scalar is then done only within that region. Note that in the mask expression we have specified the image with the Image tool im2 via im2.name() (rather than referring to its disk file name zz2).

Example

 
#  
print "\----\t replacemaskedpixels Ex 4 \t----"  
ia.maketestimage(’zz3’,overwrite=true)  
ia.maketestimage(’zz2’,overwrite=true)  
ia.maketestimage(’zz1’,overwrite=true)  
ia.calcmask(’zz1<0’)  
ia.replacemaskedpixels(’zz2+zz3’)  
ia.close()  
#  

In this example, the replacement values are taken from a LEL expression adding two other images together. The expression must conform with the image zz1.

Please send any comments or questions about CASA or AIPS++ to aips2-requests@nrao.edu

Copyright © 2007 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

Updated daily during alpha development.