Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


crops image by removing borders of uniform color.

crops image based on the size specification size.

crops image by removing pixels from sides specified by spec.

Details and OptionsDetails and Options

  • ImageCrop[image] effectively removes borders from image whose pixel value distribution is almost uniform.
  • ImageCrop[image,{w,h}] by default removes pixels symmetrically from image, or if w or h is larger than for image, it adds pixels symmetrically.
  • The image size specification size in ImageCrop[image,size] can have the following forms:
  • widthparticular width; height based on aspect ratio
    {width,height}particular width and height
    {width,depth,height}particular width, depth, and height in 3D
  • Specifications for either of the dimensions can be any of the following:
  • dd pixels
    UpTo[d]maximum d pixels
    {dmin,dmax}pixel ranges
    Automaticdetermine value from aspect ratio
    Fulldo no cropping in this dimension
  • The cropping specification spec in ImageCrop[image,size,spec] can have the following forms:
  • sidecrop on the specified side; center otherwise
    {side1,side2}crop on the specified sides
    {ax,ay}assign a fraction of cropping to each side
  • Sides can be specified as Left, Right, Bottom, or Top. Center indicates symmetrical cropping.
  • Cropping fractions are between and . In the horizontal case, is equivalent to Left, to Right, and to Center. In the vertical case, is equivalent to Bottom, and to Top.
  • ImageCrop[image,size] is equivalent to ImageCrop[image,size,Center].
  • To obtain an image with an aspect ratio r, use ImageCrop[image,width{1,r}].
  • If the final image specified by ImageCrop[image,] extends beyond image, then pixels are added according to the setting for Padding.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Automatically crop uniform borders:

Click for copyable input

Crop an image to a given size:

Click for copyable input

Crop constant areas of a 3D image:

Click for copyable input
Click for copyable input
Introduced in 2008
| Updated in 2015