views:

36

answers:

1

I'd like to convert a set of pixel values from one profiled colorspace to another, without these values residing in an image file, such as (say) a list of RGB/RGBA/CMYK/etc data structures.

I have python and PIL at my disposal (but I'm interested in solutions in related environments if that's what it takes).

The latest PIL has very nice support for littlecms -- but no way to hand it anything other than a PIL image (or a legacy pyCMS object) for it to act upon.

as far as I can ascertain, the command-line tool icctrans that's included with littlecms does something of this sort, but I can't seem to find any non-skeletal documentation on it, and the lcms doc refers to it as a demonstration tool.

+1  A: 

I got a badge called 'tumbleweeds' for this question (which is less insulting than 'crickets' or somesuch I guess) but so fine, there are two ways.

  • the hack way: to reprofile N color structures (and/or transform them between colorspaces) you create a 1x(N+2) image with PIL.Image.new(), use yourimage.load() to get a pixel-setting object interface thing, and set values (0,0) through (0,N) to whatever you got. Set (0,N+1) to white and (0,N+2) to black, and transform (or proof-transform) that image using your favorite ICC files and PIL.ImageCms.ImageCmsTransform(). Blammo: that PIL object is now your LUT. read the values off with the image.load() thingy and you're good.

  • the true-nerd way: you need to use python-colormath -- which is great for colorspace transforms but not profiling. colormath can't read ICC profiles, so either a) you get to parse their crazy binary format in a reliable way, or b) just do the math, literally. This guy Bruce Lindbloom has all the data available in excel format for, like, all of the matricies you need to reprofile your LUTs. He is totally awesome. I am still trying to 'just' feed this data into colormath.... so yeah, that makes me less awesome as I am still trying to get this 'nerd way' into something resembling production-quality.

there you go. that is what I did so far to answer the question of freestanding, commando-style ICC LUT transforms. u guys... srsly.

fish2000