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

1.1.1 Get the pixel values from a regular region of the image into an array


Description

This function returns the pixels (or optionally the pixel mask) from the image file between blc and trc inclusively. Both float and complex valued images are supported. An increment may be specified with inc. Note that if you retrieve too many pixels, you might cause swapping since the pixels are kept in memory.

Any illegal blc values are set to zero. Any illegal trc values are set to the end of the image. If any trc < blc, you get the whole image for that axis. Any illegal inc values are set to unity.

The argument axes can be used to reduce the dimensionality of the output array. It specifies which pixel axes of the image to average the data over. For example, consider a 3-D image. With axes=[0,1] and all other arguments left at their defaults, the result would be a 1-D vector, a profile along the third axis, with the data averaged over the first two axes.

A related function is getregion which retrieves the pixels or pixel mask from a potentially more complex region-of-interest. Function getchunk is retained because it is faster and therefore preferable for repeated operation in loops if the pixel mask is not required and the region is a simple box.

If you set getmask=T, the return value is the ’pixelmask’ rather than the ’pixel’ image.

Arguments





Inputs

blc

Bottom-Left-Corner (beginning) of pixel section. Default is start of image.

allowed:

intArray

Default:

-1

trc

Top-Right-Corner (end) of pixel section. Default is end of image.

allowed:

intArray

Default:

-1

inc

increment (stride) along axes

allowed:

intArray

Default:

1

axes

Axes to average over. Default is none.

allowed:

intArray

Default:

-1

list

List bounding box to logger?

allowed:

bool

Default:

false

dropdeg

Drop degenerate axes?

allowed:

bool

Default:

false

getmask

Get the pixel mask rather than the pixel values

allowed:

bool

Default:

false

Returns
anyvariant

Example

 
Suppose that we have a 3-dimensional image called {\sff im}. Then:  
 
"""  
#  
print "\t----\t getchunk Ex 1 \t----"  
ia.fromshape(shape=[64,64,128])  
pix = ia.getchunk()                      # all pixels  
ia.calcmask(’T’)                         # give image a mask  
pix = ia.getchunk([1,1,1], [10,10,1])    # 10 by 10 section of plane # 1  
pix = ia.getchunk([1,1], [1,1])          # first spectrum  
pix = ia.getchunk(inc=[1,5])             # all planes, decimated by 5 in y  
mask = ia.getchunk(getmask=T)            # Get pixelmask  
ia.close()  
#  
"""  
 

__________________________________________________________________


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