ImageFile.Stoner__Image__imagefuncs__crop(*args, **kargs)

Crop the image according to a box.


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


(ImageArray) – view or copy of array asked for


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 (analagous 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 correspoinding 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 foloows:

    • (int): A pixel co-ordinate 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 cordinate.

    • None: The extent of the image is used.