Wolfram.com
WolframAlpha.com
WolframCloud.com
Wolfram Language
Example Repository
Ready-to-use examples for the Wolfram Language
Primary Navigation
Categories
Astronomy
Audio Processing
Calculus
Cellular Automata
Chemistry
Complex Systems
Computer Science
Computer Vision
Control Systems
Creative Arts
Data Science
Engineering
Finance & Economics
Finite Element Method
Food & Nutrition
Geography
Geometry
Graphs & Networks
Image Processing
Life Sciences
Machine Learning
Mathematics
Optimization
Physics
Puzzles and Recreation
Quantum Computation
Signal Processing
Social Sciences
System Modeling
Text & Language Processing
Time-Related Computation
Video Processing
Visualization & Graphics
Alphabetical List
Submit a New Resource
Learn More about
Wolfram Language
Related Pages
Related Symbols
BrightnessEqualize
ColorDetect
ColorQuantize
ColorsNear
FindMatchingColor
ImageEffect
ImageRecolor
Related Categories
Image Processing
Computer Vision
Color-Based Segmentation
Example Notebook
Open in Cloud
Download Notebook
Segment and replace colors in images
Start with the following image:
I
n
[
1
]
:
=
i
=
;
Build a segmentation mask using a specific color reference:
I
n
[
2
]
:
=
C
o
l
o
r
D
e
t
e
c
t
[
i
,
D
a
r
k
e
r
[
G
r
e
e
n
,
.
5
]
]
O
u
t
[
2
]
=
Some colors might be difficult to guess, like the blue in the water:
I
n
[
3
]
:
=
C
o
l
o
r
D
e
t
e
c
t
[
i
,
L
i
g
h
t
e
r
[
B
l
u
e
]
]
O
u
t
[
3
]
=
Use
F
i
n
d
M
a
t
c
h
i
n
g
C
o
l
o
r
to find the best match for
B
l
u
e
in the image:
I
n
[
4
]
:
=
b
l
u
e
=
F
i
n
d
M
a
t
c
h
i
n
g
C
o
l
o
r
[
i
,
B
l
u
e
,
M
a
x
C
o
l
o
r
D
i
s
t
a
n
c
e
.
3
]
O
u
t
[
4
]
=
Build a mask with the improved reference color:
I
n
[
5
]
:
=
C
o
l
o
r
D
e
t
e
c
t
[
i
,
b
l
u
e
]
O
u
t
[
5
]
=
Multiply the original image by the mask to pull out the blue:
I
n
[
6
]
:
=
i
C
o
l
o
r
D
e
t
e
c
t
[
i
,
b
l
u
e
]
O
u
t
[
6
]
=
See Also
DesaturateExcept
ImageColorReplace
Related Symbols
BrightnessEqualize
ColorDetect
ColorQuantize
ColorsNear
FindMatchingColor
ImageEffect
ImageRecolor
Publisher Information
Contributed by:
Wolfram Staff