How to obtain N darkest colors, N brightest colors, and N most used colors from an image
Posted: 2016-03-26T10:25:44-07:00
Hi, I am trying to pull colors from an image (desktop backgrounds) to create an automated project for theming an application. Here is a testing image which has easy colors to pull from (lots of dark, medium and bright colors): http://i.imgur.com/5Wvr0xU.jpg
I would like to be able to fetch 1-N dark colors, 1-N bright colors, and 1-N most used colors from an image. I can use these as lowlights, highlights, and generic other colors in my theming process.
What I've tried already is:
Which gives me the 5 most used colors along with the number of times they were used, but it gives no distinction between dark and bright colors (for instance, browns, blacks, and dark greys would be dark colors while pinks, reds, and the like may be bright colors).
Another solution I've tried was:
Which gives me the average color of the whole image if I understand it right. Which is good, but I need multiple colors of dark/light as explained above.
So is it possible for imagemagick to distinguish between dark colors and light colors from an image and return them in hex format for usage using separate function calls? I would like to only get the dark colors, then only get the light colors, then only get the generic colors per call to imagemagick.
Thanks.
I would like to be able to fetch 1-N dark colors, 1-N bright colors, and 1-N most used colors from an image. I can use these as lowlights, highlights, and generic other colors in my theming process.
What I've tried already is:
Code: Select all
convert 5Wvr0xU.jpg +dither -colors 5 -define histogram:unique-colors=true -format "%c" histogram:info:
875250: ( 27, 21, 44) #1B152C srgb(27,21,44)
320626: ( 75, 46, 77) #4B2E4D srgb(75,46,77)
427105: ( 93, 7, 47) #5D072F srgb(93,7,47)
379734: (187, 35, 68) #BB2344 srgb(187,35,68)
70885: (237,159,144) #ED9F90 srgb(237,159,144)
Another solution I've tried was:
Code: Select all
convert 5Wvr0xU.jpg -scale 1x1\! -format '%[pixel:u]' info:-
srgb(86,29,57)
So is it possible for imagemagick to distinguish between dark colors and light colors from an image and return them in hex format for usage using separate function calls? I would like to only get the dark colors, then only get the light colors, then only get the generic colors per call to imagemagick.
Thanks.