returns dominant colors in image.


returns at most n dominant colors in image.


returns the specified property prop for the regions that belong to the same dominant color.


returns the output in the specified format.


returns dominant colors in each imagei.

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"Lab 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:
  • Automaticdetermine 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:
  • ColorCoverageAutomaticfraction of the image covered
    DistanceFunctionAutomaticany distance supported in ColorDistance
    MaskingAllregion of interest
    MethodAutomaticthe method to use
    MinColorDistanceAutomaticminimum 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


open all close all

Basic Examples  (3)

Dominant colors in an image of a logo:

Click for copyable input

Dominant colors of a grayscale image:

Click for copyable input

Dominant colors of a 3D volume:

Click for copyable input

Scope  (12)

Options  (8)

Applications  (4)

Properties & Relations  (4)

Neat Examples  (1)

Introduced in 2012
Updated in 2019