![]()
|
|||
|
|
|||
| NRAO Home > CASA > CasaDocument | |||
1.1.1 Put pixels and mask into a region-of-interest of the image
Description
This function replaces data and/or pixel mask values in the image in the
specified region-of-interest. The pixels and/or pixelmask arrays must be
the shape of the bounding box, and the whole bounding box is replaced in the
image. The region-of-interest is really only used to specify the bounding
box. If the region extends beyond the image, it is truncated. If the pixels or
pixelmask array shapes do not match the bounding box, an error will result.
When you put a pixel mask, it either replaces the current default pixel mask, or is created. The pixel mask is put before the pixels.
The argument usemask is only relevant when you are putting pixel values and there is a pixel mask (meaning also the one you might have just put in place). If usemask=T then only pixels for which the mask is good (T) are altered. If usemask=F then all the pixels in the region are altered - the mask is ignored.
The argument replicate can be used to replicate the array throughout the image (from the blc to the trc). For example, if you provide a 2D array to a 3D image, you can replicate it through the third axis by setting replicate=T. The replication is done in the specified region.
The argument locking controls two things. If True, then after the function is called, the image is unlocked (so some other process can acquire a lock) and it is indicated that the image has changed. The reason for having this argument is that the unlocking and updating processes are quite expensive. If you are repeatedly calling putregion in a for loop, you would be advised to use this switch (and to consider using putchunk).
See the related functions putchunk, set and calc.
Arguments
| Inputs |
| ||
| pixels |
| The pixel values. Default is none.
| |
| allowed: | any |
|
| Default: | variant |
|
| pixelmask |
| The pixel mask values. Default is none.
| |
| allowed: | any |
|
| Default: | variant |
|
| region |
| The region of interest. Default is whole image.
| |
| allowed: | any |
|
| Default: | record |
|
| list |
| List the bounding box and any mask creation to the
logger
| |
| allowed: | bool |
|
| Default: | false |
|
| usemask |
| Honour the mask when putting pixels
| |
| allowed: | bool |
|
| Default: | true |
|
| locking |
| Unlock image after use?
| |
| allowed: | bool |
|
| Default: | true |
|
| replicate |
| Replicate array through image
| |
| allowed: | bool |
|
| Default: | false |
|
Example
Suppose that we have a 2-dimensional image. First we recover the pixel and
pixel mask values from a polygonal region. Then we change the values in the
array that are within the region to zero and replace the data.
"""
# print "\t----\t putregion Ex 1 \t----" ia.maketestimage() # Attach an image to image tool x = [’3pix’,’6pix’,’9pix’,’6pix’,’5pix’,’5pix’,’3pix’] # X vector abs pixels y = [’3pix’,’4pix’,’7pix’,’9pix’,’7pix’,’5pix’,’3pix’] # Y vector abs pixels mycs = ia.coordsys() r1 = rg.wpolygon(x,y,csys=mycs.torecord()) # Create polygonal world region mycs.done() pixels = ia.getregion(r1) # Recover pixels pixelmask = ia.getregion(r1, getmask=T) # and mask for i in range(len(pixels)): pixels[i] = list(pixels[i]) # convert tuple to list for mods for j in range(len(pixels[i])): if pixelmask[i][j]: pixels[i][j] = 0 # Set pixels where mask is T to zero pixels[i] = tuple(pixels[i]) # convert list back to tuple ia.putregion(pixels=pixels, pixelmask=pixelmask, region=r1) # Replace pixels only ia.close() # """ |
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.