returns an image with an alpha channel where the background is transparent.


uses foreground or background model specification.


  • RemoveBackground works with arbitrary 2D and 3D images.
  • The model specification is used to indicate the foreground that is kept in the image or the background that is removed from the image.
  • Possible settings for the foreground or background model specification are:
  • specbackground specification spec
    {"Background",spec}background specification spec
    {"Foreground",spec}foreground specification spec
  • Different specifications spec may be useful for each image when separating foreground and background.
  • Specifications used for regions with almost uniform color are:
  • "Uniform"region of almost uniform color
    colregion of almost uniform color col
    markerspecify the region using a marker
    {,d}allow amount d of variation from the specified color
  • Brightness specifications can be given by:
  • "Bright"brighter foreground or background
    "Dark"darker foreground or background
  • In-focus and out-of-focus separation:
  • "Blurred"blurred region
    {"Blurred",r}assume blur factor of r
  • Markers can be given as an image, a graphics object, or a list of points {{x1,y1},{x2,y2},} in the standard image coordinate system, where x runs from 0 to width, y runs from 0 to height, and position {0,0} corresponds to the bottom-left corner of the image.
  • If an image already has an alpha channel, the result will have an alpha channel equal to the computed foreground map multiplied with the original alpha channel.


open allclose all

Basic Examples  (3)

Remove the background of an image:

Remove the background of a given color:

Remove background from a 3D image:

Scope  (8)

Separate almost uniformly colored background:

Specify the color and threshold for uniform background detection:

Specify a marker for detecting the uniform background:

Markers can also be specified by a list of coordinates:

Remove blurred background:

Separate almost uniformly colored foreground:

Specify the color for uniform foreground detection:

Specify the marker for uniform foreground detection:

Generalizations & Extensions  (1)

Background and foreground may be completely separated at multiple steps:

Remove the light yellow background:

Remove the yellow background from the temporary image:

Applications  (5)

Highlight bacteria:

Segment an object specified by a marker:

Count birds in a picture by first removing the uniform background:

Extract the shape of each component:

Detect the background in an image and replace it with fully transparent pixels:

Compose the foreground on top of a different background:

Chroma key compositing or chroma keying is a common technique to remove the background (typically green) from an image or video:

Find the shade of the green used in the background:

RemoveBackground replaces green pixels of the image with fully transparent pixels:

Compose the foreground over a slightly blurred background to also get an out-of-focus effect:

Properties & Relations  (1)

The foreground mask is stored as the alpha channel:

Use AlphaChannel to extract it:

Replace the background with a different color:

Use a background image to fill the background:

Wolfram Research (2014), RemoveBackground, Wolfram Language function,


Wolfram Research (2014), RemoveBackground, Wolfram Language function,


@misc{reference.wolfram_2021_removebackground, author="Wolfram Research", title="{RemoveBackground}", year="2014", howpublished="\url{}", note=[Accessed: 18-September-2021 ]}


@online{reference.wolfram_2021_removebackground, organization={Wolfram Research}, title={RemoveBackground}, year={2014}, url={}, note=[Accessed: 18-September-2021 ]}


Wolfram Language. 2014. "RemoveBackground." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2014). RemoveBackground. Wolfram Language & System Documentation Center. Retrieved from