I was still short an example on how to do a colour transformation using PIL and numpy with the new LittleCMS bindings:
import numpy
from PIL import Image
import littlecms
# Read an input profile from the file system.
inProfile = littlecms.Profile('../testdata/target.icc')
# Create an LCMS default profile for sRGB.
outProfile = littlecms.Profile(colourSpace=littlecms.PT_RGB)
# Create a transformation object for
# device RGB (8 bit) -> sRGB (8 bit) conversion,
# rendering intent: INTENT_PERCEPTUAL.
myTransform = littlecms.Transform(inProfile, outProfile)
# Load the image and convert it to a numpy array.
inImage = Image.open('myImage.png')
inArray = numpy.asarray(inImage)
# This one will take our output.
outArray = numpy.zeros(inArray.shape, inArray.dtype)
# Transform the image array line by line.
for i in xrange(inArray.shape[0]):
myTransform.doTransform(inArray[i], outArray[i])
# Create an image again of the output and save it.
outImage = Image.fromarray(outArray)
outImage.save('output.png')
--
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/
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 [email protected] https://lists.sourceforge.net/lists/listinfo/lcms-user
