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


uses foreground or background model specification.


performs background removal on frames of video.

Details and Options

  • RemoveBackground is also known as foreground-background segmentation. It is typically used to analyze the foreground or background or replace the background.
  • 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 model specification are:
  • specforeground or background specification spec
    {"Background",spec}background specification spec
    {"Foreground",spec}foreground specification spec
  • By default, these models are used as foreground specifications:
  • "Salient"saliency object detection based on neural networks
    "Object"semantic segmentation of foreground and background
    {"Object",params}position or bounding box specification
    Rectangle[]segment indicated by a bounding box
  • By default, these models are used as background specifications:
  • colregion of almost uniform color col
    markerimageregion of almost uniform colors specified by an image
    possegment containing the position pos
    {pos1,pos2,}segment containing all posi
    "Blurred"blurred region
    {"Blurred",r}assume blur factor of r
    "Bright"brighter foreground or background
    "Dark"darker foreground or background
    "Uniform"region of almost uniform color
    {"Uniform",params}color, position and color distance specification
  • Positions posi are assumed to be in the standard image coordinate system.
  • The following options can be given:
  • BatchSizeAutomatichow many examples to process in a batch
    PerformanceGoalAutomaticwhether to optimize for speed or quality
    TargetDevice"CPU"the target device on which to perform training
  • 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.
  • RemoveBackground for some models uses machine learning. Its methods, training sets and biases included therein may change and yield varied results in different versions of the Wolfram Language.
  • RemoveBackground may download resources that will be stored in your local object store at $LocalBase, and can be listed using LocalObjects[] and removed using ResourceRemove.


open allclose all

Basic Examples  (3)

Remove the background of an image:

Remove the background of a given color:

Remove the background using saliency object detection:

Scope  (14)

Basic Uses  (5)

Remove the background from an image:

Remove the background using a background specification:

Remove the background using a foreground specification:

Remove the background from a video:

Remove the background from a 3D image:

Model Specification  (9)

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:

Separate background from a salient foreground segmentation:

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, (updated 2023).


Wolfram Research (2014), RemoveBackground, Wolfram Language function, (updated 2023).


Wolfram Language. 2014. "RemoveBackground." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023.


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


@misc{reference.wolfram_2024_removebackground, author="Wolfram Research", title="{RemoveBackground}", year="2023", howpublished="\url{}", note=[Accessed: 25-April-2024 ]}


@online{reference.wolfram_2024_removebackground, organization={Wolfram Research}, title={RemoveBackground}, year={2023}, url={}, note=[Accessed: 25-April-2024 ]}