« reshelve the entire university library by color | Main | Project for Public Spaces: Why Libraries Matter More Than Ever (Cynthia Nikitin, Josh Jackson) »

23 April 2007

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: , , , ,

Comments

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

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.

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

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!

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

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

What they're saying about Superpatron

  • So you've got Ed exploring the possibility space, and John working to enlarge that space, and together they've created a virtuous cycle of innovation. Now this is obviously an extreme example. You are not going to find a superpatron of Ed's caliber and a superlibrarian of John's caliber in every town. But I think the dynamic at work there can apply more broadly. And if it does, it will matter that these patrons and librarians are situated in a local context. (Jon Udell, Remixing the Library, GRL2020)
  • Der Supernutzer beschreibt 10 Möglichkeiten, der Bibliothek zu helfen....Den wichtigsten Punkt hat er vergessen, ihn aber selbst erfüllt. Sozusagen als Präambel könnte man also anführen:

    “Übe konstruktive Kritik an der Bibliothek. Ohne Resonanz können die Leute da drin nicht wissen, was Du willst.” Infobib.de

  • How come only some books in the Google Book Search have “find in a library” links next to them? Diglet asks, and gets an answer, sort of a lame one if you ask me. update: Kevin mentioned in the comments that it would be great to see this for all books in Google Books. I went to bed thinking “Oh yeah, I should look into that….” and while I was sleeping, Superpatron, aka Ed Vielmetti solved the crime, er problem, and created a Greasemonkey script (a plug-in that you can run with Firefox) that does this for Ann Arbor and can be modified for any library. (Jessamyn West)
  • Curse you Superpatron! t's way past my bedtime, but the Ann Arbor Superpatron has been planting ideas in my head again… (Dave Pattern)
  • Superpatron is a blog run by a patron. The author posts entries about events and articles relevant to the library community, but does it with a patron point of view. (North Texas Regional Library System)
  • The blogosphere's resident "awesomest patron ever," Edward Vielmetti, appears in an article in School Library Journal about how he wrote a script tweaking (ahem, improving) Google Book Search. Vielmetti's blog, Superpatron, is one I read daily and highly recommend to anyone in libraries looking to get a very smart user's perspective. (Librarian In Black)
  • When I wrote him back, I called him the “AADL Super Patron,” which is very coincidental, since he has been planning to create a blog with almost the same name. Today, Superpatron is live and I’m sure it will quickly be filled with Ed’s terrific ideas about making libraries more responsive to patrons’ needs. So hurry up and subscribe already, ok? (Meredith Farkas)
  • The Superpatron (faster than a speeding reference librarian…) posts a presentation on the use of del.icio.us for research. Steven Cohen, Library Stuff
  • I've talked about Edward Vielmetti here before, but I never had the right name for him. Now I do. He's Superpatron! (Jenny Levine)
  • Last fall, in Ann Arbor, Michigan, I gave a talk entitled Superpatrons and Superlibrarians. Joining me for this week’s podcast are the two guys who inspired that talk. The superpatron is Ed Vielmetti, an old Internet hand who likes to mash up the services proviced by the Ann Arbor District Library. That’s possible because superlibrarian John Blyberg, who works at the AADL, has reconfigured his library’s online catalog system, adding RSS feeds and a full-blown API he calls PatREST. (Jon Udell)
  • Little did I know that when I pointed to Ed Vielmetti’s blog, I was not only coining a phrase, but providing the name for Ed’s brilliant new blog. Ed is that (unfortunately still) rare creature that not only groks the net in fullness, but also has use for his public library. (Eli Neiburger)
  • Die Ann Arbor District Library hat einen Nutzer, der sie liebt. Und nicht nur das, er schreibt darüber. Oliver Obst

mybloglog


Blog powered by TypePad