File Exchange

image thumbnail

image2palette: Simple K-means color clustering

version 1.0.1 (30.6 KB) by HioBeen Han
Clustering pixel colors of image (K-means) in L/a/b color space to make palette.

7 Downloads

Updated 28 Nov 2018

View Version History

View License

image2palette() parses image into pixels in L/a/b space, and returns major color components clustered by k-means method. It also returns the name of colors and palette.

--- Usage example

%% (1) Version 1. Pre-defined image
nCluster = 4;
imagefullpath = [pwd, '\' 'football.jpg'];
image2palette( nCluster, imagefullpath );

%% (2) Version 2. Select image using GUI handle
nCluster = 4;
image2palette( nCluster )

Color label reference: https://en.wikipedia.org/wiki/Web_colors

Cite As

Hio-Been Han (2018). image2palette: Simple K-means color clustering, MATLAB Central File Exchange. Retrieved November 28, 2018.

Comments and Ratings (1)

Victor Morais

Hey, im dont really understand what are you displaying in the console. I mean, for example Crimson colour in hex is #DC3127, but in the display you put [ 48,65,49 ] and if i try to write this down in a rgb online paleete give me another colour. I would like to know how to extract the exact color in the display. Thnks.

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: rgb2hex and hex2rgb

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!