NRAO Home > CASA > CASA Toolkit Reference Manual
regionmanager.box - Function

1.1.2 Create a pixel box region


Description

This function creates a multi-dimensional pixel box region. The box is specified by a bottom-left corner, and top-right corner and an increment (or stride). Pixel coordinates are considered to run from 1 at the bottom left corner of the image to the image shape at the top-right corner of the image.

You can specify whether the coordinates are given as pixel coordinates (frac=F) or fractions of the image shape (frac=T). Absolute fractions are in the range [0,1].

You can also specify whether the coordinates are given as absolute coordinates (absrel=’abs’) or relative to the reference pixel (absrel=’relref’) or relative to the center of the image (absrel=’relcen’).

Arguments





Inputs

blc

blc of the box

allowed:

doubleArray

Default:

0

Unity

trc

trc of the box

allowed:

doubleArray

Default:

-1

Shape

inc

increment

allowed:

doubleArray

Default:

1

absrel

Absolute or relative coordinates

allowed:

string

Default:

relref

relcen

abs

frac

Pixel or fractional coordinates

allowed:

bool

Default:

false

F

comment

A comment stored with the region

allowed:

string

Default:

Returns
record

Example

 
 
ia.open(’myimage’)  
ia.shape()  
[155 178 256]  
 
r = rg.box()                 # create region  
-  
- ia.boundingbox(r)  
[blc=[1 1 1] , trc=[155 178 256] , inc=[1 1 1] , bbShape=[155 178 256] ,  
regionShape=[155 178 256] , imageShape=[155 178 256] ]  
 
 
This region, on application to an image, selects the entire image.  
 

Example

 
 
- ia.open(’myimage’)  
- ia.shape()  
[155 178 256]  
-  
- r=rg.box(blc=[5,10])  
- ia.boundingbox(r)  
[blc=[5 10 1] , trc=[155 178 256] , inc=[1 1 1] , bbShape=[151 169 256] ,  
regionShape=[151 169 256] , imageShape=[155 178 256] ]  
 
 
This region is only specified for the first two axes of the blc.  
Automatic extension rules apply for the other axis and the trc  
(defaults to the shape).  
 

Example

 
 
- ia.open(’myimage’)  
- ia.shape()  
[155 178 256]  
-  
- r = rg.box(blc=[10, 10, 10], trc=[20, 20, 20], inc=[2, 2, 2])  
- ia.boundingbox(r)  
[blc=[10 10 10] , trc=[20 20 20] , inc=[2 2 2] , bbShape=[11 11 11] ,  
regionShape=[6 6 6] , imageShape=[155 178 256] ]  
-  
stats=ia.statistics(region=r, list=False);  
stats[’npts’][0]  
216  
 
 
This region picks out every other pixel in the 3D box.  The  
‘‘regionShape’’ field of the bounding box record does reflect the  
increment whereas ‘‘bbShape’’ does not.  You can see that the number of  
points used in determining the statistics (216) reflects the increment  
as well.  
 

Example

 
 
THIS EXAMPLE IS NOT VALID YET  
 
- ia.open(’myimage’)  
- ia.shape()  
[64 128]  
-  
- rmd = rg.dflt()  
- r = rg.box([-5,-10], [rmd,20], absrel=’relcen’)  
-  
- ia.boundingbox(r)  
[blc=[28 55] , trc=[64 85] , inc=[1 1] , bbShape=[37 31] ,  
regionShape=[37 31] , imageShape=[64 128] ]  
 
 
The region is specified in pixels relative to the center of the image.  
Note the use of the default value ({\cf rg.dflt()}) to default the first  
axis of the trc argument to the image shape without having to know the  
image shape.  
 

Example

 
 
- ia.open(’myimage’)  
- ia.shape()  
[155 178 256]  
-  
- summ=ia.summary(list=False)  
- summ[’header’][’refpix’]  
[90 90 1]  
-  
- r = rg.box([-0.25,-0.3], [0.25, 0.5], frac=True, absrel=’relref’)  
- ia.boundingbox(r)  
[blc=[39 37 1] , trc=[116 178 256] , inc=[1 1 1] , bbShape=[78 142 256] ,  
regionShape=[78 142 256] , imageShape=[155 178 256] ]  
 
 
This example shows selection by relative to reference pixel fractional  
coordinates plus auto extension to unspecified axes.  
 

__________________________________________________________________


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