What color (or hue) is that book?
Dave Pattern and I had an exchange (via Facebook and his blog) about how to efficiently extract the color of a book from Amazon's cover images database. He turned it into a web service, and I turned that web service into a shell script for your scripting needs. Both very raw and beta (alpha really). See
http://library.hud.ac.uk/balti/bookcolor.pl?isbn=0545010225 - XML interface
http://library.hud.ac.uk/balti/bookcolor2.pl?isbn=0545010225 - web interface
http://www.superpatron.com/wall-of-books/book-color.sh - shell script
I have not turned that (yet) into "book search results sorted by color", which I think is as easy as pulling down an RSS feed of search results, pulling a color for each, and doing the sort. Alas RGB color values prove hard to sort into a rainbow as is, so you might want to use
http://library.hud.ac.uk/balti/bookcolor.pl?isbn=0545010225&colorspace=HSL
the colorspace=HSL parameter to return (hue, saturation, luminance) instead of (red, green, blue). My color theory ends here, anyone know how to build a rainbow?
Technorati Tags: color, colour, huddersfield, amazon, web-services
I've also added "colorspace=HSB" as an option (Hue/Saturation/Brightness) which I think is the same as "HSV", just in case that turns out to be an easier value to build a rainbow from.
I've had a couple of stabs at creating a rainbow but I've not found the magic formula yet. Sorting by hue works well as a starting point, but there's obviously more to it than that.
One issue is that the average color of the book cover can sometimes seem odd -- for example, if half the book is blue and the other half is red, then the average is purple. Or should that be, if you're feeling blue and you've only read half the book, then it's purple? ;-D
If anyone is looking for a random-ish feed of ISBNs to play with, then you can use this:
http://webcat.hud.ac.uk/data/catalogue/covers/recent.txt
Posted by: Dave Pattern | 24 April 2007 at 01:42 AM
Yeah, I wondered about the kinds of muted colors that are coming out of there.
Should there be some way to pick out the "dominant colors" of a book, something like a histogram or spectrogram and pick out the peaks? That white book with black print is really white, not gray, or maybe it's 90% white, 10% black with a stripe.
Wikipedia turns up this other color space, which might actually work better - it plots things on a 3d space, but if you ignore "lightness" you could go 2d with it and then do your wall of books with a
http://en.wikipedia.org/wiki/L*a*b
which bunches things together pretty nicely.
Posted by: Edward | 24 April 2007 at 02:08 AM
I'm using ImageMagick, so I'm limited to the colorspaces that it supports:
http://www.imagemagick.org/script/command-line-options.php#colorspace
Another option would be to use the "height" and "width" parameters to fetch back more pixel averages.
If you pull back a 3x3 (which gives you 9 hex values), that white book with black print should give you more more values that are closer to white.
For example, if you take a look at this book cover:
http://webcat.hud.ac.uk/covers/bib/365781.jpg
Then the average color is a greyish green:
http://library.hud.ac.uk/balti/bookcolor2.pl?isbn=0672320541
If you bring back the 3x3 data, then you get more of a flavor of the cover:
http://library.hud.ac.uk/balti/bookcolor2.pl?isbn=0672320541&height=3&width=3
With a 6x6, then you can see that most of the cover is whiteish:
http://library.hud.ac.uk/balti/bookcolor2.pl?isbn=0672320541&height=6&width=6
Posted by: Dave Pattern | 24 April 2007 at 06:16 AM
Still not quite there, but I've been playing with looking at the mean value(s) compared to the average color.
This page fetches a random book cover and displays the average color, along with some of the mean values:
http://161.112.232.18/perl/color2.pl
First of all it resamples the images to 30x30 pixels and then looks at the general colour of each of the 900 pixels. If there are any colors which appear in more than 5% of the pixels, then those are listed.
If you want to see a specific book, then include the ISBN in the URL, e.g.
http://161.112.232.18/perl/color2.pl?0672320541
I'm not sure if this really helps us get that rainbow, but it's kinda fun just playing around!
Posted by: Dave Pattern | 25 April 2007 at 02:53 AM
Note Dave's pointer to recent work here:
http://www.daveyp.com/blog/index.php/archives/291
and the Colourphon service under development
http://vielmetti.typepad.com/superpatron/2008/03/colourphon---bo.html
Posted by: Edward Vielmetti | 12 March 2008 at 11:47 PM