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

1.1.1 Get the bounding box of the specified region


Description

This function finds the bounding box of a region of interest when it is applied to a particular image. Both float and complex valued images are supported. It is returned in a record which has fields ‘blc’, ‘trc’, ‘inc’, ‘bbShape’, ‘regionShape’, ‘imageShape’, ‘blcf’ and ‘trcf’ containing the bottom-left corner, the top-right corner (in absolute image pixel coordinates), the increment (stride) of the region, the shape of the boundingbox, the shape of the region, the shape of the image, the blc in formatted absolute world coordinates and the trc in formatted absolute world coordinates, respectively.

Note that the shape of the bounding box will be different from the shape of the region if a non-unit stride (increment) is involved (see the example below).

Note that the integer size of the elements in blc, trc, inc, regionShape, bbShape, and imageShape are 32 bits, even on a 64 bit machine. This means that, on 64 bit machines, you may have to convert them to 64 bit ints using eg numpy.int64, before being able to use them as direct input to other methods such as ia.getchunk().

Arguments





Inputs

region

Region selection. Default is to use the full image.

allowed:

any

Default:

variant

Returns
record

Example

 
 
"""  
#  
print "\t----\t boundingbox Ex 1 \t----"  
ia.maketestimage()                           # Create image tool  
x=[’3pix’,’6pix’,’9pix’,’6pix’,’5pix’,’5pix’,’3pix’] # X vector in abs pixels  
y=[’3pix’,’4pix’,’7pix’,’9pix’,’7pix’,’5pix’,’5pix’] # Y vector in abs pixels  
mycs = ia.coordsys()  
r1=rg.wpolygon(x=x,y=y,csys=mycs.torecord()) # Create polygonal world region  
mycs.done()  
bb = ia.boundingbox(r1)                      # Find bounding box  
print bb  
#{’regionShape’: array([7, 7]), ’trc’: array([9, 9]),  
# ’imageShape’: array([113, 76]),  
# ’blcf’: ’00:00:27.733, -00.06.48.000’,  
# ’trcf’: ’00:00:24.533, -00.05.36.000’, ’bbShape’: array([7, 7]),  
# ’blc’: array([3, 3]), ’inc’: array([1, 1])}  
ia.close()  
#  
"""  
 

Example

 
 
"""  
#  
print "\t----\t boundingbox Ex 2 \t----"  
ia.maketestimage()  
b = rg.box([10,10],[20,20],[2,3])  
print ia.boundingbox(b)  
#{’regionShape’: array([6, 4]), ’trc’: array([20, 19]),  
# ’imageShape’: array([113,  76]),  
# ’blcf’: ’00:00:24.000, -00.05.24.000’,  
# ’trcf’: ’00:00:18.667, -00.03.36.000’, ’bbShape’: array([11, 10]),  
# ’blc’: array([10, 10]), ’inc’: array([2, 3])}  
 
ia.close()  
#  
"""  
 
In this example we see the difference between bbShape and regionShape because  
of the increment (stride).  See also that the trc is modified by  
the increment.  

__________________________________________________________________


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