Here's a simple example using my object oriented Python API for LCMS with the 
ctypes library bindings. It uses numpy arrays as the native input/output data 
type of the buffers for conversion. The conversion uses a profile in the file 
system for input, and a built in profile for output. Here I'm converting 8 
bit RGB to floating point Lab.

So far I have added the basics for profile and transformation handling, and 
I've tried to automate as many things as possible to make it as easy to use, 
but with the option pass certain features in as optional parameters if 
needed. Transformations work e. g. with and without given output buffer. This 
way in-place transformations, or transformations into existing buffers (or 
images) are possible, as well as in the example the creation of a new 
suitable matrix to store the values.

Any comments?

Guy


import numpy
import Lcms

# Read an input profile from the file system.
myProfile = Lcms.Profile('testdata/target.icc')

# Create an LCMS default profile for Lab.
labProfile = Lcms.Profile(colourSpace=Lcms.PT_Lab)

# Create a transformation object for
# device RGB (8 bit) -> Lab (double) conversion,
# rendering intent INTENT_PERCEPTUAL.
myTransform = Lcms.Transform(myProfile, labProfile, outputDepth=0)

rgbColours = numpy.array([[159, 189, 63],
                         [230, 162, 39]],
                        dtype=numpy.uint8)

# Transform just one colour tuple
labColours = myTransform.doTransform(rgbColours)

print 'RGB colours:\n', rgbColours
print 'Lab colours:\n', labColours


-- 
Guy K. Kloss
Institute of Information and Mathematical Sciences
Te Kura Pūtaiao o Mōhiohio me Pāngarau
Room 2.63, Quad Block A Building
Massey University, Auckland, Albany
Private Bag 102 904, North Shore Mail Centre
voice: +64 9 414-0800 ext. 9585   fax: +64 9 441-8181
eMail: [EMAIL PROTECTED]  http://www.massey.ac.nz/~gkloss/

Attachment: signature.asc
Description: This is a digitally signed message part.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to