Function Repository Resource:

Colorfulness

Source Notebook

Quantify the color variation in an image

Contributed by: Andy Hunt

ResourceFunction["Colorfulness"][image]

calculates the color variation in image.

Details

This uses one subjective measure of variation. Different methods might of course give different results.
This function works on images and on graphics that become images on using ColorConvert with "RGB" as the second argument.

Examples

Basic Examples (2) 

Determine colorfulness of an image:

In[1]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/ac9b278c-89f6-48c0-b6cf-a28a9aa8c7f6"]
In[2]:=
ResourceFunction["Colorfulness"][img]
Out[2]=

Colorfulness varies with pixel intensities:

In[3]:=
Grid[{ResourceFunction["Colorfulness"][#], #} & /@ {img, ImageAdjust[img, 1], ImageAdjust[img, {0, -0.5}]}]
Out[3]=

Sort graphics by colorfulness:

In[4]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/07511dc6-ab3e-432b-9586-d56ae786a0fb"]
In[5]:=
Grid[Sort[{ResourceFunction["Colorfulness"][#], #} & /@ graphicsList]]
Out[5]=

Scope (3) 

Black lacks visual interest:

In[6]:=
gr = Graphics[{Black, Rectangle[]}]
Out[6]=
In[7]:=
ResourceFunction["Colorfulness"][gr]
Out[7]=

Make an image of a plot:

In[8]:=
gr = Rasterize@Plot[Sin[x], {x, 0, Pi}]
Out[8]=

Compute the colorfulness (or lack thereof):

In[9]:=
ResourceFunction["Colorfulness"][gr]
Out[9]=

Rasterize a 3-D plot:

In[10]:=
gr = Rasterize@Plot3D[Sin[x + y^2], {x, 0, Pi}, {y, 0, Pi}]
Out[10]=

Calculate the colorfulness:

In[11]:=
ResourceFunction["Colorfulness"][gr]
Out[11]=

Neat Examples (2) 

Colorful images of flower symmetry:

In[12]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/2782b284-9697-45af-8257-fe0e296ff821"]
In[13]:=
Grid[Sort[{ResourceFunction["Colorfulness"][#], Thumbnail[#, Tiny]} & /@ flowerImages]]
Out[13]=

Colorful images of victorian wallpaper:

In[14]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/693f4fed-3d63-4e9c-9fe4-392fff422d71"]
In[15]:=
Grid[Sort[{ResourceFunction["Colorfulness"][#], Thumbnail[#, Tiny]} & /@ wallpaperImages]]
Out[15]=

Publisher

Andy Hunt

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 06 April 2026

Source Metadata

Related Resources

License Information