BorderDimensions

BorderDimensions[image]

gives the pixel width of uniform borders of image in the form {{left,right},{bottom,top}}.

BorderDimensions[image,t]

finds borders whose pixels vary by an amount less than t.

Details and Options

Background & Context

  • BorderDimensions computes the constant or semi-uniform border or frame around a 2D or 3D image and returns them as an array of integer values of the form {{left,right},{bottom,top}} (for an Image) or {{left,right},{bottom,top},{bottom,top}} (for an Image3D). With an optional second argument, BorderDimensions finds borders whose pixels vary by an amount less than a given threshold.
  • Border dimensions of a uniform image are considered zero.
  • ImagePad can be used to remove the detected border from an image. ImageCrop is another function that can be used to crop an almost-uniform border. However, unlike BorderDimensions, ImageCrop does not allow specification of a variance threshold.

Examples

open allclose all

Basic Examples  (1)

Find the pixel dimensions of the black margins:

Scope  (3)

Border dimensions of a grayscale image:

Specify a higher tolerance to detect a noisy image border:

Border dimensions of a 3D volume:

Applications  (3)

Remove blue borders of a color image:

Extract the text part of a scanned book:

Extract the foreground objects over a smoothly shaded background:

Properties & Relations  (1)

Border dimensions of a uniform image are considered zero:

Introduced in 2010
 (8.0)
 |
Updated in 2012
 (9.0)