|
|||
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.
- First, you can give the pixels argument a simple numeric scalar (e.g. pixels=1.0). Then, all masked values will be replaced by that value.
- Second, you can give a scalar LEL expression string (e.g. pixels=’min(myimage)’). Then, all masked values will be replaced by the scalar that results from the expression. If the scalar expression is illegal (e.g. in the expression pixels=’min(myimage)’ there were no good pixels in myimage) then the value 0 is used for replacement.
-
Third,
you
can
give
a
LEL
expression
string
which
has
the
same
shape
as
the
image
file you
are
applying
the
function
to.
For
example,
putting
pixels=’myotherimage’
means
replace
all
masked
pixels
in
this
image
file with
the
equivalent
pixel
in
the
image
file called
myotherimage.
Your expression might be quite complex, and you can think of it as producing another masked lattice. However, in the replace process, the mask of that expression lattice is ignored. Thus, only the mask of the image file you are replacing and the pixel values of the expression lattice are relevant.
The expression must conform with the subimage formed by applying the region-of-interest to the image (i.e. that associated with this Image tool). If you use the mask argument as well, the region-of-interest is applied to it as well (see examples).
Arguments
Inputs |
| ||
pixels |
| The new value(s), Numeric scalar or LEL expression
| |
| allowed: | any |
|
| Default: | variant | |
region |
| Region selection. See ”help par.region” for details.
Default is to use the full image.
| |
| allowed: | any |
|
| Default: | variant
|
|
mask |
| Mask to use. See help par.mask. 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? See help
par.stretch. Default False
| |
| allowed: | bool |
|
| Default: | false |
|
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=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 {\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