NRAO Home > CASA > CASA Toolkit Reference Manual
image.replacemaskedpixels - Function

1.1.1 replace the values of pixels which are masked bad


Description

This application replaces the values of all pixels whose total input mask (default input pixel mask and OTF mask) is bad (F) with the specified value. It supports both float valued and compplex valued images.

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

Region selection. Default is to use the full image.

allowed:

any

Default:

variant

mask

Mask to use. 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

stretch

Stretch the mask if necessary and possible? Default False

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  
{\sff 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 {\sff zz1} has no mask.  By using the {\stfaf 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 {\sff 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=rg.box([0.25,0.25],[0.75,0.75],frac=true)  
ia.replacemaskedpixels(0.0, region=r, mask=im2.name(strippath=True)+’>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 {\stfaf mask} expression  
as well - this means that any images in the {\stfaf mask} expression  
must conform with the {\sff zz1} image.   The replacement of the  
scalar is then done only within that region.  Note that in  
the {\stfaf mask} expression we have specified the image with  
the Image tool {\stf im2} via im2.name() (rather than referring  
to its disk file name {\sff 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 {\sff zz1}.  

__________________________________________________________________


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

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