User Rating 0.0
Total Usage 0 times
Category CSS Tools
Drop image here or click to upload
HEX
RGB
HSL
Luminance
Is this tool helpful?

Your feedback helps us improve.

About

Computing the arithmetic mean of multiple colors is not a trivial visual operation. The human eye perceives brightness non-linearly, which means a naive average in raw RGB space can produce results that appear perceptually darker than expected. This calculator computes the channel-wise mean across R, G, and B for any set of input colors, and optionally applies ITU-R BT.709 luminance weighting (coefficients 0.2126, 0.7152, 0.0722) for perceptually balanced results. It also extracts the dominant average from uploaded images by sampling every pixel via Canvas getImageData(). Incorrect color averaging leads to muddy palettes in design systems, inaccurate data visualization legends, and broken gradient midpoints. The tool assumes sRGB color space and does not perform gamma correction, which introduces an error of approximately 5 - 12% in perceived lightness for highly saturated inputs.

average color color mixer mean color color calculator image average color rgb average hex average color blending

Formulas

The arithmetic mean color is computed by averaging each RGB channel independently across n input colors:

Ravg = 1n ni=1 Ri

The same formula applies to the G and B channels. For image averaging, n equals the total pixel count (width × height).

Relative luminance per ITU-R BT.709:

Y = 0.2126 R + 0.7152 G + 0.0722 B

Conversion from RGB to HSL uses the standard algorithm: H is derived from the channel with maximum value, S = C1 |2L 1| where C is the chroma (max min of normalized channels), and L = max + min2.

Where: R, G, B = channel values (0 - 255); n = number of colors; Y = relative luminance; H = hue in degrees; S = saturation; L = lightness; C = chroma.

Reference Data

Color NameHEXRGBHSLLuminance (BT.709)
White#FFFFFF255, 255, 2550°, 0%, 100%1.000
Black#0000000, 0, 00°, 0%, 0%0.000
Pure Red#FF0000255, 0, 00°, 100%, 50%0.2126
Pure Green#00FF000, 255, 0120°, 100%, 50%0.7152
Pure Blue#0000FF0, 0, 255240°, 100%, 50%0.0722
Cyan#00FFFF0, 255, 255180°, 100%, 50%0.7874
Magenta#FF00FF255, 0, 255300°, 100%, 50%0.2848
Yellow#FFFF00255, 255, 060°, 100%, 50%0.9278
Orange#FF8C00255, 140, 033°, 100%, 50%0.4817
Purple#800080128, 0, 128300°, 100%, 25%0.0697
Coral#FF7F50255, 127, 8016°, 100%, 66%0.4474
Teal#0080800, 128, 128180°, 100%, 25%0.1940
Slate Gray#708090112, 128, 144210°, 13%, 50%0.4818
Gold#FFD700255, 215, 051°, 100%, 50%0.8424
Tomato#FF6347255, 99, 719°, 100%, 64%0.3930
Steel Blue#4682B470, 130, 180207°, 44%, 49%0.4524
Olive#808000128, 128, 060°, 100%, 25%0.4639
Salmon#FA8072250, 128, 1146°, 93%, 71%0.4730
Indigo#4B008275, 0, 130275°, 100%, 25%0.0533
Ivory#FFFFF0255, 255, 24060°, 100%, 97%0.9896

Frequently Asked Questions

Arithmetic averaging in linear RGB produces #800080 (purple with 50% intensity per channel). Because sRGB is gamma-encoded, this value appears perceptually darker than a true midpoint. For perceptually accurate results, you would need to linearize the sRGB values (apply inverse gamma), average, then re-encode. This tool operates in sRGB space, which matches how CSS and browsers handle color mixing.
Pixels with an alpha channel value below 10 (out of 255) are skipped entirely. Semi-transparent pixels (alpha ≥ 10) are included with their RGB values as-is, without premultiplying against a background. This prevents white or black backgrounds from skewing the average when processing PNGs with transparency.
Arithmetic RGB treats all three channels equally. Luminance-weighted averaging applies ITU-R BT.709 coefficients (R × 0.2126, G × 0.7152, B × 0.0722) to compute a single brightness value per color, then weights each color's contribution to the final average proportionally. This produces results that feel more balanced to human perception, especially when mixing colors of very different brightness levels.
HSL averaging is problematic because hue is a circular value (0° and 360° are the same red). Averaging hue = 10° and hue = 350° arithmetically gives 180° (cyan), which is wrong - the correct mean is 0° (red). This tool uses RGB space because channel values are linear scalars without circular discontinuities. If you need hue-based blending, convert to a Cartesian representation of hue first.
The Canvas API processes all pixels, but images larger than approximately 4000 × 4000 pixels (16 megapixels) may cause noticeable lag on mobile devices. The tool scales images exceeding 2 megapixels down to a maximum of 1000px on the longest side before sampling, preserving color distribution while maintaining responsiveness. The original image is not modified.
RGB channels are computed as floating-point averages, then rounded to the nearest integer using Math.round(). This introduces a maximum error of ±0.5 per channel, which corresponds to less than 0.2% deviation - imperceptible to the human eye. The HEX string is derived from these rounded integers.