RemoveBackgroundCopy to clipboard.
✖
RemoveBackground

returns an image with an alpha channel where the background is transparent.
uses foreground or background model specification.
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:
-
spec foreground 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 "People" people segmentation Rectangle[…] segment indicated by a bounding box - By default, these models are used as background specifications:
-
col region of almost uniform color col markerimage region of almost uniform colors specified by an image pos segment 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:
-
BatchSize Automatic how many examples to process in a batch PerformanceGoal Automatic whether 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.


Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Remove the background of an image:

https://wolfram.com/xid/05ftvcq0uu-h63rr0

Remove the background of a given color:

https://wolfram.com/xid/05ftvcq0uu-1t1qzq

Remove the background using saliency object detection:

https://wolfram.com/xid/05ftvcq0uu-byrd11

Remove the background from a picture of a person:

https://wolfram.com/xid/05ftvcq0uu-p458c

Scope (16)Survey of the scope of standard use cases
Basic Uses (5)
Remove the background from an image:

https://wolfram.com/xid/05ftvcq0uu-hz6vtt

Remove the background using a background specification:

https://wolfram.com/xid/05ftvcq0uu-t3k8p1

Remove the background using a foreground specification:

https://wolfram.com/xid/05ftvcq0uu-qlgp9n

Remove the background from a video:

https://wolfram.com/xid/05ftvcq0uu-wl7apo


https://wolfram.com/xid/05ftvcq0uu-thykwo

Remove the background from a 3D image:

https://wolfram.com/xid/05ftvcq0uu-jtb49m

Background Specification (5)
Separate an almost uniformly colored background:

https://wolfram.com/xid/05ftvcq0uu-r6gmvh

Specify the color and threshold for uniform background detection:

https://wolfram.com/xid/05ftvcq0uu-ek3fm7

Specify a marker for detecting the uniform background:

https://wolfram.com/xid/05ftvcq0uu-m0dwl1

Markers can also be specified by a list of coordinates:

https://wolfram.com/xid/05ftvcq0uu-gg90ax


https://wolfram.com/xid/05ftvcq0uu-0i2kwc

Removing the background using background model specification is equivalent:

https://wolfram.com/xid/05ftvcq0uu-5exs1b

Foreground Specification (6)
Separate the background from a salient foreground segmentation:

https://wolfram.com/xid/05ftvcq0uu-831001


https://wolfram.com/xid/05ftvcq0uu-oxzc1b

Segment the foreground using the "Object" model:

https://wolfram.com/xid/05ftvcq0uu-y9xgfi

Remove the background using a point marker as the object specification:

https://wolfram.com/xid/05ftvcq0uu-bnk8mm


https://wolfram.com/xid/05ftvcq0uu-bd7qh9

Remove the background using a rectangle marker as the object foreground specification:

https://wolfram.com/xid/05ftvcq0uu-lye0n4


https://wolfram.com/xid/05ftvcq0uu-5rgqn

Separate an almost uniformly colored foreground:

https://wolfram.com/xid/05ftvcq0uu-sfy1au

Specify the color for uniform foreground detection:

https://wolfram.com/xid/05ftvcq0uu-j67g4s

Generalizations & Extensions (1)Generalized and extended use cases
Background and foreground may be completely separated at multiple steps:

https://wolfram.com/xid/05ftvcq0uu-0u1og4
Remove the light yellow background:

https://wolfram.com/xid/05ftvcq0uu-oehwu9

Remove the yellow background from the temporary image:

https://wolfram.com/xid/05ftvcq0uu-pdewwz


https://wolfram.com/xid/05ftvcq0uu-hipa3g

Options (2)Common values & functionality for each option
BatchSize (1)
Applications (6)Sample problems that can be solved with this function
Remove the background of a video with people in the foreground:

https://wolfram.com/xid/05ftvcq0uu-jca9qe

https://wolfram.com/xid/05ftvcq0uu-xul9hx


https://wolfram.com/xid/05ftvcq0uu-js1sz1

Segment an object specified by a marker:

https://wolfram.com/xid/05ftvcq0uu-rb6q9r

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

https://wolfram.com/xid/05ftvcq0uu-uvhlcy


https://wolfram.com/xid/05ftvcq0uu-1mqz6l

Extract the shape of each component:

https://wolfram.com/xid/05ftvcq0uu-js9mxj

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

https://wolfram.com/xid/05ftvcq0uu-rbvam6

https://wolfram.com/xid/05ftvcq0uu-0hbceb

Compose the foreground on top of a different background:

https://wolfram.com/xid/05ftvcq0uu-hvynr0

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

https://wolfram.com/xid/05ftvcq0uu-rmv6yl
Find the shade of the green used in the background:

https://wolfram.com/xid/05ftvcq0uu-xuqzap

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

https://wolfram.com/xid/05ftvcq0uu-3bbd2a

https://wolfram.com/xid/05ftvcq0uu-io0ek7

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

https://wolfram.com/xid/05ftvcq0uu-nsm96o

https://wolfram.com/xid/05ftvcq0uu-m1m689

Properties & Relations (1)Properties of the function, and connections to other functions
The foreground mask is stored as the alpha channel:

https://wolfram.com/xid/05ftvcq0uu-tzd8yk

Use AlphaChannel to extract it:

https://wolfram.com/xid/05ftvcq0uu-sb2qqf

Replace the background with a different color:

https://wolfram.com/xid/05ftvcq0uu-pfgr4v

Use a background image to fill the background:

https://wolfram.com/xid/05ftvcq0uu-ers5fd

Possible Issues (2)Common pitfalls and unexpected behavior
When using the object method, specifying a point or a region can improve the result significantly:

https://wolfram.com/xid/05ftvcq0uu-iaaqxw

https://wolfram.com/xid/05ftvcq0uu-kmotue


https://wolfram.com/xid/05ftvcq0uu-nxxf91

Different methods may provide better results depending on the image content and the region of interest:

https://wolfram.com/xid/05ftvcq0uu-dl00a3

https://wolfram.com/xid/05ftvcq0uu-il9x3i

Compare to the "Object" model:

https://wolfram.com/xid/05ftvcq0uu-o30y9j

Wolfram Research (2014), RemoveBackground, Wolfram Language function, https://reference.wolfram.com/language/ref/RemoveBackground.html (updated 2024).
Text
Wolfram Research (2014), RemoveBackground, Wolfram Language function, https://reference.wolfram.com/language/ref/RemoveBackground.html (updated 2024).
Wolfram Research (2014), RemoveBackground, Wolfram Language function, https://reference.wolfram.com/language/ref/RemoveBackground.html (updated 2024).
CMS
Wolfram Language. 2014. "RemoveBackground." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/RemoveBackground.html.
Wolfram Language. 2014. "RemoveBackground." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/RemoveBackground.html.
APA
Wolfram Language. (2014). RemoveBackground. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RemoveBackground.html
Wolfram Language. (2014). RemoveBackground. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RemoveBackground.html
BibTeX
@misc{reference.wolfram_2025_removebackground, author="Wolfram Research", title="{RemoveBackground}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/RemoveBackground.html}", note=[Accessed: 27-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_removebackground, organization={Wolfram Research}, title={RemoveBackground}, year={2024}, url={https://reference.wolfram.com/language/ref/RemoveBackground.html}, note=[Accessed: 27-March-2025
]}