Re: PyOpenColorIO - Converting a simple singe RBG array to another colorspace

Larry Gritz

Which versions of OIIO and OCIO are you using?

I'm not sure that official releases of OCIO (prior to the current master) will work with 8 bit integer pixels, which is what you'd get from a jpeg by default. So it may be misinterpreting the values.

If you read with

    pixels = img.read_image(format='float')

then you'll get float pixels, and perhaps that will match what Nuke is doing?

As somewhat of an aside, maybe this is a contrived example and you need to do a lot more with PyOpenColorIO, but if all you are doing is color converting pixels you read with OIIO, an easier idiom would be:

img = oiio.ImageBuf('test_image.jpg')'float')
oiio.ImageBufAlgo.colorconvert(img, img, 'Raw', 'Film_EIZO')
pixels = img.get_pixels()

and then you don't need to directly import or use OpenColorIO at all. (Though this assumes you built your OIIO with OCIO enabled.)

On Jun 3, 2020, at 12:55 PM, mhamid3d@... wrote:

Hi all,

I am new to this and hoping to get some help. I have a simple single pixel RGB value that is in a Raw color space. I would like to convert it to another colorspace. I have the following code, which produced no errors but I'm not getting the values I'm expecting. As reference I'm using Nuke with the OCIOColorSpace node. I made sure to set my Display Transform to None in Nuke. Then I created a simple constant with pure red. (1, 0, 0) and exported it as a Raw colorspace jpg. Loaded that into PyOpenColorIO and ran the code bellow. It returns a value very different from the one I'm getting Nuke. Am I doing something wrong?

import PyOpenColorIO as ocio
import OpenImageIO as oiio

config = ocio.GetCurrentConfig()
proc = config.getProcessor('Raw', 'Film_EIZO')

img ='test_image.jpg')
pixels = img.read_image()

imgd = proc.applyRGB(pixels)
print imgd

Larry Gritz

Join { to automatically receive all group messages.