🌐
TinEye Labs
labs.tineye.com β€Ί color
TinEye Labs - Color Extraction Lab
MulticolorEngine will display a color palette for all the colors identified in your image. Color extraction works for JPEGs, PNGs, and GIFs.
🌐
10015
10015.io β€Ί tools β€Ί image-color-extractor
Image Color Extractor Online | 10015 Tools
Online Image Color Extractor is a free tool for extracting colors from an image from 2 to 10 colors. You can get details of each color and copy all of them as a list.
🌐
Colormind
colormind.io β€Ί image
Colormind - smart image color extraction
Generate pleasing color schemes from images. Upload your image and Colormind will extract relevant colors and arrange it in a cohesive color palette
🌐
mdigi.tools
mdigi.tools β€Ί color-extractor
Color Palette Extractor - mdigi.tools
Simply drop the image file in the area above and a color palette will be built using the colors present in the image. Our Color Palette Extractor can build a color pallete of 9 different color shades after picking these colors from the image.
🌐
Online PNG Tools
onlinepngtools.com β€Ί extract-png-color-palette
Extract PNG Color Palette – Online PNG Maker
World's simplest online Portable Network Graphics (PNG) color palette extractor. Just import your PNG image in the editor on the left and you will instantly get a list of all the most popular colors used in it on the right.
🌐
Coolphptools
coolphptools.com β€Ί color_extract
Image Color Extract Tool - Cool PHP Tools
The Image Color Extract PHP class pulls the most common colors out of an image file. The color values are in hexidecimal. You can try it out below. Upload a file or use the sample image provided. This class was originally written by Csongor Zalatnai. You can get his original version here: ...
🌐
Adobe
color.adobe.com β€Ί create β€Ί image
Color theme from image | Adobe Color
Color Wheel Β· Extract Theme Β· Extract Gradient Β· Accessibility Tools Β· Replace Image Β· or Select a file from your computer Β· Save Β· What's New Β· Colors in Adobe Express Β· More & Less Colors Β· Vector Recolor Β· Contrast Checker Β· Color blind safe themes Β·
Find elsewhere
🌐
11Zon
bigimage.11zon.com β€Ί en β€Ί extract-color
Colors from Image - Best Color Extractor from Image
You can see all the colors on the list with the HEX color code. Also, you can see the most used color of the image on this tool with HEX code. Now, you can copy the HEX color and use it where you want. So, using colors from image tool, you can extract colors from the image online.
🌐
Image Color Picker
imagecolorpicker.com
πŸ‘ Color Picker online | HEX Color Picker | HTML Color Picker
Color Picker:Color Picker: With this online tool you can upload an image or provide a website URL and get the RGB Color, HEX Color and HSL Color code. πŸ‘
🌐
Online PNG Tools
onlinepngtools.com β€Ί extract-color-from-png
Extract a Color from a PNG – Online PNG Maker
World's simplest online utility that extracts objects from a PNG image by their color. Free, quick, and powerful. Import a PNG – extract objects by color.
🌐
Pixelait
pixelait.com β€Ί our blog β€Ί ui β€Ί 6 best tools to extract colors from an image
6 best tools to extract colors from an image - Learn Everything About Designing UIs with AI | Pixelait Blog
August 4, 2024 - Coolors is an intuitive and fast color scheme generator that provides palettes from uploaded images. Users can adjust and refine these palettes, making it a universal tool for quick color inspiration. Generate quick palettes with Coolors; for UI text styles, read β€œWhat is a Monospaced Font? 7 Best Use Cases.β€œ Β· Coolors: Intuitive and fast color scheme generator Β· TinEye shines in color extraction by offering a unique search-by-color option. This feature allows designers to find images based on specific colors, which is invaluable for creating color-themed designs or collections.
🌐
Reddit
reddit.com β€Ί r/artistlounge β€Ί tool to extract colour gamut from image?
r/ArtistLounge on Reddit: Tool to extract colour gamut from image?
February 10, 2022 -

Is there a tool / method in a given drawing software of extracting all of the colours from an image, mapped onto a colour wheel?

The closest I have found is hexcolor but it produces an unordered list of colours which is hard to parse. Other sites max out at 10 or so colours extracted.

My desire is to see, on a colour wheel, what colours an artist used in a given work. Is there a better way of doing this?

I have a vague memory of seeing this kind of software mentioned for use with analyzing colour in film screencaps but may be wrong.

Thank you!

🌐
Terra for Spatix
terrasolid.com β€Ί guides β€Ί tscan β€Ί prjextractcolorfromimages.html
Extract color from images
Extract color from images command extracts RGB color values from raster images and assigns the color values to laser points in block binary files. The color sources can be orthophotos attached as TerraPhoto raster references or raw images in an active TerraPhoto image list.
🌐
GitHub
github.com β€Ί luukdv β€Ί color.js
GitHub - luukdv/color.js: Extract colors from an image (0.75 KB) 🎨
import { prominent } from 'color.js' prominent('js-logo.jpg', { amount: 1 }).then(color => { console.log(color) // [241, 221, 63] }) // Or with different syntax: const color = await prominent('js-logo.jpg', { amount: 1 }) console.log(color) // [241, 221, 63] ... colorjs.prominent('js-logo.jpg', { amount: 1 }).then(color => { console.log(color) // [241, 221, 63] }) Returns the most used color(s) in an image.
Starred by 392 users
Forked by 23 users
Languages Β  TypeScript 54.8% | JavaScript 45.2%
🌐
Medium
shegocodes.medium.com β€Ί extracting-all-colors-in-images-with-python-2e36eb8a67d2
Extracting All Colors in Images with Python | by Shegocodes | Medium
October 21, 2024 - Extracting and analyzing every 10th pixel will do. color_codes = get_color_codes(detected_colors[0::10]) # list splice Β· Finally, I returned all the closest matches with its associated color names. Results are stored in a pandas dataframe. def get_association(color_codes): """ Function returns color name associated w/ detected color codes. Parameters ---------- color_codes : list list of detected color codes in image Return ------ res : list list of color names associated with respective color codes """ res = [] for color_code in color_codes: colorfile = os.path.join('colors', color_code + '.png') # Query color name associated with color code colorname = colors[colors['code'] == f'#{color_code}'] color_name = ['color'].values[0] # Append results...
🌐
Brandfolder
brandfolder.com β€Ί workbench β€Ί color-palette
Extract Colors from Image | Generate a Color Palette | Brandfolder
Use Brandfolder Workbench to extract colors from an image or document to create your own color palette. Simple, easy & fast.
Top answer
1 of 2
1

One of the possibilities is to use webcolors package. I modified your code to find the name of the closest matching color on the color palette:

import cv2
import numpy as np
from PIL import Image
from sklearn.cluster import KMeans
import webcolors
from webcolors import CSS3_HEX_TO_NAMES, hex_to_rgb

image_path = "Photo1.png"
num_colors = 5
num_clusters = 5

def get_dominant_colors(image_path, num_colors=10, num_clusters=5):
    image = Image.open(image_path)
    image = image.resize((200, 200))
    image = image.convert('RGB')
    img_array = np.array(image)
    pixels = img_array.reshape(-1, 3)
    kmeans = KMeans(n_clusters=num_clusters, random_state=0)
    labels = kmeans.fit_predict(pixels)
    centers = kmeans.cluster_centers_
    color_counts = {}
    for label in np.unique(labels):
        color = tuple(centers[label].astype(int))
        color_counts[color] = np.count_nonzero(labels == label)
    sorted_colors = sorted(color_counts.items(), key=lambda x: x[1], reverse=True)
    dominant_colors = [color for color, count in sorted_colors[:num_colors]]
    color_occurrences = [count for color, count in sorted_colors[:num_colors]]
    dominant_colors_hex = ['#%02x%02x%02x' % color for color in dominant_colors]
    return dominant_colors_hex, color_occurrences

dominant_colors, color_occurrences = get_dominant_colors(image_path, num_colors, num_clusters)

def closest_color(hex):
    colors = {}
    for key, name in CSS3_HEX_TO_NAMES.items():
        r_c, g_c, b_c = hex_to_rgb(key)
        rd = (int(hex[1:3], 16) - r_c) ** 2
        gd = (int(hex[3:5], 16) - g_c) ** 2
        bd = (int(hex[5:7], 16) - b_c) ** 2
        colors[(rd + gd + bd)] = name
    return colors[min(colors.keys())]
print("Dominant colors: ")

for col in dominant_colors:
    col_name = closest_color(col)
    print(col_name)

palette_height = 100
palette_width = 100 * num_colors
palette = np.zeros((palette_height, palette_width, 3), dtype=np.uint8)

start_x = 0
for color_hex in dominant_colors:
    color_rgb = tuple(int(color_hex[i:i+2], 16) for i in (1, 3, 5))
    end_x = start_x + 100
    palette[:, start_x:end_x] = color_rgb
    start_x = end_x

palette_image = Image.fromarray(palette)
palette_bgr = cv2.cvtColor(np.array(palette_image), cv2.COLOR_RGB2BGR)

cv2.imshow("Palette", palette_bgr)
cv2.waitKey(0)
cv2.destroyAllWindows()

You can swap the color mapping from CSS3 to HTML4, for example. It includes names for the 16 base colors Here you can find more. Just replace the line

for key, name in CSS3_HEX_TO_NAMES.items():

with

for key, name in HTML4_HEX_TO_NAMES.items():
2 of 2
0

This is the code I ended up using when I had to figure something similar out.

The above image shows that the .HTML table it generates upon hovering show sthe frequency and color name / hex value of the color. Also, if you click the color block it'll copy that hex value.

[import cv2
import numpy as np
from PIL import Image
from sklearn.cluster import KMeans
from webcolors import CSS3_HEX_TO_NAMES, hex_to_rgb

# Specify the path to the image file
image_path = "Picture.png"

def get_dominant_colors(image_path, num_colors=10, num_clusters=5):
    """
    Utilizes KMeans clustering to identify dominant colors in an image.
    """
    image = Image.open(image_path)
    image = image.resize((200, 200))
    image = image.convert('RGB')

    img_array = np.array(image)
    pixels = img_array.reshape(-1, 3)
    kmeans = KMeans(n_clusters=num_clusters, random_state=0)
    labels = kmeans.fit_predict(pixels)
    centers = kmeans.cluster_centers_
    color_counts = {}
    for label in np.unique(labels):
        color = tuple(centers\[label\].astype(int))
        color_counts\[color\] = np.count_nonzero(labels == label)
    sorted_colors = sorted(color_counts.items(), key=lambda x: x\[1\], reverse=True)
    dominant_colors = \[color for color, count in sorted_colors\[:num_colors\]\]
    color_occurrences = \[count for color, count in sorted_colors\[:num_colors\]\]
    dominant_colors_hex = \['#%02x%02x%02x' % color for color in dominant_colors\]
    return dominant_colors_hex, color_occurrences

def closest_color(hex):
    """
    Finds the closest matching color name from CSS3 colors.
    """
    colors = {}
    for key, name in CSS3_HEX_TO_NAMES.items():
        r_c, g_c, b_c = hex_to_rgb(key)
        rd = (int(hex\[1:3\], 16) - r_c) ** 2
        gd = (int(hex\[3:5\], 16) - g_c) ** 2
        bd = (int(hex\[5:7\], 16) - b_c) ** 2
        colors\[(rd + gd + bd)\] = name
    return colors\[min(colors.keys())\]

def rgb_to_hex(rgb):
    """
    Converts RGB tuple to hexadecimal color representation.
    """
    return '#{:02x}{:02x}{:02x}'.format(rgb\[0\], rgb\[1\], rgb\[2\])

def get_colors(image_path):
    """
    Retrieves all distinct colors present in the image.
    """
    image = Image.open(image_path)
    image = image.resize((200, 200))
    image = image.convert('RGB')

    # Fetch pixel colors
    pixels = list(image.getdata())

    # Identify unique colors
    unique_colors = list(set(pixels))

    return unique_colors

# Obtain dominant colors
dominant_colors_hex, color_occurrences = get_dominant_colors(image_path)

# Display extracted color names
print("Extracted Colors:")
for col_hex in dominant_colors_hex:
    col_name = closest_color(col_hex)
    print(col_name)

# Write distinct colors and their counts to a text file
with open(image_path.split('.')\[0\] + "_Color_List.txt", 'w') as f:
    for col_hex, col_occ in zip(dominant_colors_hex, color_occurrences):
        col_name = closest_color(col_hex)
        print(f"{col_name} \[{col_occ}\]", file=f)

# Convert colors to hexadecimal representation
distinct_colors = get_colors(image_path)
distinct_colors_hex = \[rgb_to_hex(color) for color in distinct_colors\]

# Generate HTML color table
html_content = "<!DOCTYPE html>\n<html>\n<head>\n<style>\ntable {\nborder-collapse: collapse;\n}\ntd {\nborder: 1px solid black;\nwidth: 15px;\nheight: 15px;\n}\n</style>\n<script>\nfunction copyColor(hex) {\n  var dummy = document.createElement('textarea');\n  document.body.appendChild(dummy);\n  dummy.value = hex;\n  dummy.select();\n  document.execCommand('copy');\n  document.body.removeChild(dummy);\n}\n</script>\n</head>\n<body>\n<table>"
html_content += "\n<tr>"
for color, count, hex_code in zip(dominant_colors_hex, color_occurrences, distinct_colors_hex):
    color_name = closest_color(color)
    html_content += f"\n<td title='{color_name} ({hex_code}), {count} times' style='background-color:{color}' onclick='copyColor(\"{color}\")'></td>"
html_content += "\n</tr>\n</table>\n</body>\n</html>"

# Write HTML content to file
with open(image_path.split('.')\[0\] + "_Color_Table.html", 'w') as f:
    f.write(html_content)][1]