Thanks Larry! That totally did it! This is actually a small snippet of my code. I actually go on to update workingImage with this new buffer and pass it along the pipe. I was just writing out the exr there to try and debug why this colorspace stuff wasn't working correctly.
While I've got your eyes, is there something I'm missing conceptually about the ColorProcessors with more than rgb channels? If I send in rgba, I get back an image with no alpha anymore, regardless of the unpremult parameter. I would hope that I could just skip doing color processing on the channel. I know there's an roi param, the current default behavior seems a little odd. On Fri, Feb 17, 2017 at 10:02 AM, Larry Gritz <[email protected]> wrote: > My guess is that the source image, "my_rgba_image.tif", is uint8 or > uint16. So when you do the colorconvert into an uninitialized ImageBuf, it > makes the transformed data have the same data format as the input. It > doesn't know at that point that you wish to eventually write it out as an > EXR that can handle floating point. > > Assuming my hypothesis is right, here's how to fix: > > ImageBuf* workingImage = new ImageBuf("my_rgba_image.tif"); > > *ImageSpec newspec = workingimage->spec(); // Copy spec of input...* > *newspec.set_format (OIIO::TypeDesc::FLOAT); // ...but change data type to > float* > > *ImageBuf labSpaceBuffer (newspec); // ...and use that to > initialize the buffer* > > ColorProcessor* unsharpSpaceProcessor = config.createColorProcessor("linear", > "CIE Lab D65"); > bool result = ImageBufAlgo::colorconvert(labSpaceBuffer, *workingImage, > unsharpSpaceProcessor, true); > labSpaceBuffer.write("test_out.exr"); > > > Extra note: don't forget to delete workingimage at the end! (Since you > allocated a new ImageBuf, instead of just making one directly on the stack > as you did with labSpaceBuffer.) > > > On Feb 17, 2017, at 9:50 AM, Andrew Wood <[email protected]> wrote: > > Hey there! > > I'm playing around with OCIO to do a transform from linear to CIELAB space > to do an unsharpen. I've got a config.ocio that gives me the expected > results in Nuke just fine, however using oiio and ocio, I'm getting a very > different result. > > CIELAB does use negative numbers, so I'm wondering if there is some issue > with those in oiio? I convert to lab, and then write out an exr, and there > aren't any negative values in there... > > My code looks something like this: > > ImageBuf* workingImage = new ImageBuf("my_rgba_image.tif"); > ColorProcessor* unsharpSpaceProcessor = config.createColorProcessor("linear", > "CIE Lab D65"); > > ImageBuf labSpaceBuffer; > bool result = ImageBufAlgo::colorconvert(labSpaceBuffer, > *workingImage, unsharpSpaceProcessor, true); > labSpaceBuffer.write("test_out.exr") > > Using Nuke on the source image, I expect to see negative values in the > green and blue channels, but looking at test_out.exr they seem to be > clamped at 0. > > config.ocio looks something like this (based on linear), but since it > looks correct in Nuke, and not in my code, I must be doing something wrong! > https://gist.github.com/andrewhwood/badb691a5c940af670fe3b9f8cfb189f > > any ideas? > thanks! > Andrew > > _______________________________________________ > Oiio-dev mailing list > [email protected] > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > > > -- > Larry Gritz > [email protected] > > > > _______________________________________________ > Oiio-dev mailing list > [email protected] > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > >
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
