ImageFile.Stoner__Image__imagefuncs__crop¶
- ImageFile.Stoner__Image__imagefuncs__crop(*args, **kargs)¶
Crop the image according to a box.
- Parameters:
box (tuple) – (xmin,xmax,ymin,ymax) If None image will be shown and user will be asked to select a box (bit experimental)
- Keyword Arguments:
copy (bool) – If True return a copy of ImageFile with the cropped image
- Returns:
(ImageArray) – view or copy of array asked for
Notes
This is essentially like taking a view onto the array but uses image x,y coords (x,y –> col,row) Returns a view according to the coords given. If box is None it will allow the user to select a rectangle. If a tuple is given with None included then max extent is used for that coord (analogous to slice). If copy then return a copy of self with the cropped image.
- The box can be specified in a number of ways:
(int): A border around all sides of the given number pixels is ignored.
(float 0.0-1.0): A border of the given fraction of the images height and width is ignored
(string): A corresponding item of metadata is located and used to specify the box
(tuple of 4 ints or floats): For each item in the tuple it is interpreted as follows:
(int): A pixel coordinate in either the x or y direction
(float 0.0-1.0): A fraction of the width or height in from the left, right, top, bottom sides
(float > 1.0): Is rounded to the nearest integer and used a pixel coordinate.
None: The extent of the image is used.
Example
a=ImageFile(np.arange(12).reshape(3,4))
a.crop(1,3,None,None)