bounding_box¶

mpdaf.obj.
bounding_box
(form, center, radii, shape, posangle=0.0, step=None)[source]¶ Return Yaxis and Xaxis slice objects that bound a rectangular image region that just encloses either an ellipse or a rectangle, where the rectangle has a specified center position, Yaxis and Xaxis radii, and a given rotation angle relative to the image axes. The effective center of the region is also returned.
If the ellipse or rectangle is partly outside of the image array, the returned slices are clipped at the edges of the array. The effective center that is returned, is the center before clipping.
 Parameters
 form
str
The type of region whose rectangle image bounds are needed, chosen from: rectangle, a rotated rectangle or square. ellipse, a rotated ellipse or circle.
 center
float
,float
The floating point array indexes of the centre of the circle, in the order, y,x.
 radii
float
or float,float The halfwidth and halfheight of the ellipse or rectangle. When the posangle is zero, the width and height are parallel to the X and Y axes of the image array, respectively. More generally, the width and height are along directions that are posangle degrees counterclockwise of the X axis and Y axis, respectively. If only one number is specified, then the width and the height are both given that value.
 posangle
float
The counterclockwise rotation angle of the chosen shape, in degrees. When posangle is 0 degrees, the width and height of the shape are along the X and Y axes of the image. Nonzero values of posangle rotate the chosen shape anticlockwise of that position.
 shape
int
,int
The dimensions of the image array.
 step
float
,float
The perpixel worldcoordinate increments along the Y and X axes of the image array, or [1.0,1.0] if radii is in pixels.
 form
 Returns
 out
clipped
,unclipped
,center
The ‘clipped’ return value is a list of the Yaxis and Xaxis slices to use to select all pixels within the rectangular region of the image that just encloses the part of the ellipse or rectangle that is within the image area.
The ‘unclipped’ returnvalue is the version of ‘clipped’ before it was clipped at the edges of the image.
The ‘center’ return value is the pixel index of the center of the region, prior to clipping.
If the region is entirely outside the range of an axis, a zeropixel slice is returned for that axis in ‘clipped’, with a start value that is 0 if the pixels were all below pixel 0, or shape1 if they were all off the upper end of the range.
 out