DominantColors
returns the specified property prop for the regions that belong to the same dominant color.
Details and Options



- DominantColors[image] returns a list of colors that represent clusters of colors that appear in the image. The colors are represented by GrayLevel or RGBColor.
- DominantColors works with arbitrary 2D and 3D images.
- The returned colors are ordered based on the size of the clusters they represent.
- DominantColors uses the LABColor to find color clusters.
- The following properties can be used to return dominant colors in different forms:
-
"Color" color for each cluster given in RGB or grayscale (default) "HexRGBColor" RGB color in the hexadecimal form "LABColor" CIELAB color "NearestHTMLColor" name of the nearest HTML color - Other supported properties include:
-
"Count" total number of pixels covered by each cluster "Coverage" fraction of the whole image covered by each cluster "CoverageImage" image representing the region covered by each cluster "MaskCoverage" fraction of the specified mask covered by each cluster - DominantColors[image,n,{"prop1","prop2",…}] computes multiple properties.
- DominantColors[image,n,"Properties"] returns a list of supported properties.
- The format argument specifies the output format. Possible settings are:
-
Automatic determine the output automatically "ColorAssociation" an association of coli{…,valj,…} "ColorPropertyAssociation" an association of coli<…,propjvalj,… > "Dataset" a Dataset of cluster properties "List" a nested list "PropertyAssociation" an association of propj{…,vali,…} - DominantColors accepts the following options:
-
ColorCoverage Automatic fraction of the image covered DistanceFunction Automatic any distance supported in ColorDistance Masking All region of interest Method Automatic the method to use MinColorDistance Automatic minimum color distance - With MinColorDistance->d, clusters represented by colors c1 and c2 are merged if ColorDistance[c1,c2]<d. The color with the larger coverage is assigned to the new cluster.
- With ColorCoverage->f, colors that cover less than a fraction f of the image are returned. With ColorCoverage->{fmin,fmax} a range of coverage fractions can be specified.
- With Masking->roi, "CoverageImage" and "MaskCoverage" return properties with respect to the specified region of interest roi. »
- Possible settings for Method include:
-
"KMeans" -means clustering algorithm
"KMedoids" partitioning around medoids "MedianCut" recursively split the color space based on median pixel values "MinVariance" recursively split the color space so that the sum of variances in new subregions is minimal (Wu's algorithm) "Octree" create an octree from all image pixels and merge leaves until the most representative remain

Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Scope (12)Survey of the scope of standard use cases
Basic Uses (4)
Find dominant colors in an image:

https://wolfram.com/xid/05fql6gr8m-egqz2h

Compute up to 5 dominant colors:

https://wolfram.com/xid/05fql6gr8m-3tcfmc

Compute different properties for each dominant color:

https://wolfram.com/xid/05fql6gr8m-wuw5ec

Compute the dominant colors of a list of images:

https://wolfram.com/xid/05fql6gr8m-mw9foi

Properties (6)
By default, dominant colors are returned as RGB colors:

https://wolfram.com/xid/05fql6gr8m-ovyi3m

Dominant colors represented in CIELAB space:

https://wolfram.com/xid/05fql6gr8m-6lowkj

Return the dominant colors in their hexadecimal representation:

https://wolfram.com/xid/05fql6gr8m-88smcc

Find the closest HTML color name to each dominant color:

https://wolfram.com/xid/05fql6gr8m-q1w4q7

Compute the number of pixels covered by each dominant color:

https://wolfram.com/xid/05fql6gr8m-b9mt0a

Return coverage fraction and coverage mask:

https://wolfram.com/xid/05fql6gr8m-yhub8p

Options (8)Common values & functionality for each option
ColorCoverage (1)
By default, an automatic threshold is used for ColorCoverage:

https://wolfram.com/xid/05fql6gr8m-lbihxb

https://wolfram.com/xid/05fql6gr8m-9srssl

Return all colors regardless of their coverage:

https://wolfram.com/xid/05fql6gr8m-ymrwqs

If no color covers the minimum coverage specified, an empty list is returned:

https://wolfram.com/xid/05fql6gr8m-zdknr4

Specify a range for color coverage:

https://wolfram.com/xid/05fql6gr8m-ovay1c

DistanceFunction (1)
By default, the "CIE76" color distance is used to merge color clusters:

https://wolfram.com/xid/05fql6gr8m-u0ho8r

https://wolfram.com/xid/05fql6gr8m-drdhoy

Use a different color distance:

https://wolfram.com/xid/05fql6gr8m-858l44

Specify a custom distance function between CIELAB colors:

https://wolfram.com/xid/05fql6gr8m-d51wq

Masking (2)
By default, dominant colors in the whole image are returned:

https://wolfram.com/xid/05fql6gr8m-mf1ohw

https://wolfram.com/xid/05fql6gr8m-q5j4zg

This is equivalent to the setting Masking->All:

https://wolfram.com/xid/05fql6gr8m-5hwqyu

Compute the dominant colors of the image foreground:

https://wolfram.com/xid/05fql6gr8m-osforn


https://wolfram.com/xid/05fql6gr8m-3aecjc

With Masking->All, "Coverage" and "MaskCoverage" are the same:

https://wolfram.com/xid/05fql6gr8m-su2054

https://wolfram.com/xid/05fql6gr8m-tqb1f9

With a given mask, "MaskCoverage" returns the fraction of mask covered by each cluster:

https://wolfram.com/xid/05fql6gr8m-pcnxzc

https://wolfram.com/xid/05fql6gr8m-f7tfbv

Method (2)
By default, DominantColors automatically picks the most suitable method to generate color clusters:

https://wolfram.com/xid/05fql6gr8m-o89htt

https://wolfram.com/xid/05fql6gr8m-1uprp2

Use the Method option to choose a specific method:

https://wolfram.com/xid/05fql6gr8m-xqkrct

Compare the timing and result of different methods:

https://wolfram.com/xid/05fql6gr8m-s8n5qu

MinColorDistance (2)
By default, the minimum color distance is automatically chosen:

https://wolfram.com/xid/05fql6gr8m-e7m2y

With MinColorDistance->d, clusters with color representatives closer than d are merged:

https://wolfram.com/xid/05fql6gr8m-w2wwce

Use MinColorDistance->0 to avoid any color merging:

https://wolfram.com/xid/05fql6gr8m-ce0ucd

Avoid color merging by computing all dominant colors using MinColorDistance->0:

https://wolfram.com/xid/05fql6gr8m-vx9v53

https://wolfram.com/xid/05fql6gr8m-ioamjv

Delete similar colors using a custom function:

https://wolfram.com/xid/05fql6gr8m-dfns0x

Applications (4)Sample problems that can be solved with this function

https://wolfram.com/xid/05fql6gr8m-f3osxq

Separate an image into the regions of its dominant colors:

https://wolfram.com/xid/05fql6gr8m-9crvv2

https://wolfram.com/xid/05fql6gr8m-42xwxr


https://wolfram.com/xid/05fql6gr8m-5qse7r

Create a quantized version of an image:

https://wolfram.com/xid/05fql6gr8m-y8631y

https://wolfram.com/xid/05fql6gr8m-nfq8wg

Add more details by preventing any merger:

https://wolfram.com/xid/05fql6gr8m-9owdy9

Segment cells of different colors:

https://wolfram.com/xid/05fql6gr8m-coq9qs

Properties & Relations (4)Properties of the function, and connections to other functions
Dominant colors are sorted based on their area coverage:

https://wolfram.com/xid/05fql6gr8m-44d9hq

The alpha channel is taken into account in computing dominant colors:

https://wolfram.com/xid/05fql6gr8m-jssag9

Blend the partially transparent image with the background to get a result similar to the visual appearance of the image:

https://wolfram.com/xid/05fql6gr8m-065vsz

ColorQuantize represents the image with the existing color tones in an image:

https://wolfram.com/xid/05fql6gr8m-z7949v

Colors generated by DominantColors:

https://wolfram.com/xid/05fql6gr8m-eoedgk

Replace pixels by the closest common color in the RGB color space:

https://wolfram.com/xid/05fql6gr8m-mgtovx

Perform the color replacement in the CIELAB color space:

https://wolfram.com/xid/05fql6gr8m-ie2rsf

List of supported properties that can be computed for any dominant color:

https://wolfram.com/xid/05fql6gr8m-ux59h5

Neat Examples (1)Surprising or curious use cases
Use ArrayPlot to show the colors and their relative frequency in one plot:

https://wolfram.com/xid/05fql6gr8m-tis9iy


https://wolfram.com/xid/05fql6gr8m-2dmaud

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