Date
1 - 2 of 2
Python apply .cube ?
tre...@...
Please help!
I am trying to load in a file, resize it, apply a .cube LUT then write it out.
I have the following so far, but I'm falling over between the oiio > ocio parts (one using an oiio.ImgBuf and the other using a pixel array)
Have I missed something ? Is there an easier way to apply a .cube LUT to an image.
Thanks for any pointers !
Trevor
#load in file & resize
origBuffer = oiio.ImageBuf(aFile)
resizeBuffer = oiio.ImageBuf(oiio.ImageSpec (1920, 972, 3, oiio.FLOAT))
oiio.ImageBufAlgo.resize(resizeBuffer, origBuffer)
config = OCIO.Config()
transform = OCIO.FileTransform(src = self.LUT, interpolation = self.interpolation, direction = OCIO.Constants.TRANSFORM_DIR_FORWARD)
processor = config.getProcessor(transform)
pixels=self.inputNode.get_pixels()
img = processor.applyRGBA(pixels)
img.write(outputPath)
I am trying to load in a file, resize it, apply a .cube LUT then write it out.
I have the following so far, but I'm falling over between the oiio > ocio parts (one using an oiio.ImgBuf and the other using a pixel array)
Have I missed something ? Is there an easier way to apply a .cube LUT to an image.
Thanks for any pointers !
Trevor
#load in file & resize
origBuffer = oiio.ImageBuf(aFile)
resizeBuffer = oiio.ImageBuf(oiio.ImageSpec (1920, 972, 3, oiio.FLOAT))
oiio.ImageBufAlgo.resize(resizeBuffer, origBuffer)
config = OCIO.Config()
transform = OCIO.FileTransform(src = self.LUT, interpolation = self.interpolation, direction = OCIO.Constants.TRANSFORM_DIR_FORWARD)
processor = config.getProcessor(transform)
pixels=self.inputNode.get_pixels()
img = processor.applyRGBA(pixels)
img.write(outputPath)
tre...@...
to answer my own question:
It seems I had the wrong idea about how the FileTransform worked.
From Configs/nuke-default/make.py :
create the colorspace, then appy using oiio.ImageBufAlgo.colorconvert
cs = OCIO.ColorSpace(name='sRGB')
cs.setDescription("Standard RGB Display Space")
cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
cs.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
cs.setAllocationVars([RANGE[0], RANGE[1]])
t = OCIO.FileTransform('srgb.spi1d', interpolation=OCIO.Constants.INTERP_LINEAR)
cs.setTransform(t, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
config.addColorSpace(cs)
It seems I had the wrong idea about how the FileTransform worked.
From Configs/nuke-default/make.py :
create the colorspace, then appy using oiio.ImageBufAlgo.colorconvert
cs = OCIO.ColorSpace(name='sRGB')
cs.setDescription("Standard RGB Display Space")
cs.setBitDepth(OCIO.Constants.BIT_DEPTH_F32)
cs.setAllocation(OCIO.Constants.ALLOCATION_UNIFORM)
cs.setAllocationVars([RANGE[0], RANGE[1]])
t = OCIO.FileTransform('srgb.spi1d', interpolation=OCIO.Constants.INTERP_LINEAR)
cs.setTransform(t, OCIO.Constants.COLORSPACE_DIR_TO_REFERENCE)
config.addColorSpace(cs)