>       # output buffer
>       if destination.split('.')[-1].lower() == 'dpx':
>               format = oiio.UINT16
>       else:
>               format = oiio.FLOAT
> 
>       output_buffer = oiio.ImageBuf(oiio.ImageSpec (width, height, 
> framebuffer_channels, format))

Don't do that! That will limit the buffer itself to 16 bit integer values.  
Allocate the buffer as float.

You generally will want all internal computations to be in float, and use 
uint16 just as a detail of the output file format. What you want is this, at 
the end:

>       if destination.split('.')[-1].lower() == 'dpx':
>               output_buffer.write_format (oiio.UINT16)
>               output_buffer.specmod().attribute('oiio:BitsPerPixel', 10)
>       # otherwise leave as float
> 
>       # write
>       output_buffer.write(destination)

So this is just giving instructions for how to write the file to disk, not 
changing the precision of any internal buffers.


> On Sep 13, 2017, at 11:02 AM, Elliott Smith <[email protected]> wrote:
> 
> Good afternoon,
> 
> I'm trying to mimic the behaviour of oiiotool with the python bindings.
> 
> The command I want to mimic is:
> 
> oiiotool inputfile.exr --resize:filter=cubic 1920x1080 --colorconvert linear 
> AlexaV3LogC -d  uint16 -o outfile.dpx
> 
> When I perform this via oiiotool, I get a dpx that matches the one I get from 
> nuke. When I do this via the bindings, the highlights seem to be clamped.
> 
> The code I'm using is as follows, as well as a screengrab of the difference 
> i'm seeing when I stop down the exposure.
> 
> Any suggestions would be most welcome.
> 
> Elliott
> 
> def convert(source, destination, input_colorspace, output_colorspace, width, 
> height, filtername, working_colorspace='linear'):
> 
>       framebuffer = oiio.ImageBuf(source)
>       framebuffer_width = framebuffer.spec().width
>       framebuffer_height = framebuffer.spec().height  
>       framebuffer_channels = framebuffer.nchannels
> 
>       if width == 0:
>               width = framebuffer_width
>       if height == 0:
>               height = framebuffer_height             
> 
>       # linearise
>       oiio.ImageBufAlgo.colorconvert(framebuffer, framebuffer, 
> input_colorspace, working_colorspace)
> 
>       # output buffer
>       if destination.split('.')[-1].lower() == 'dpx':
>               format = oiio.UINT16
>       else:
>               format = oiio.FLOAT
> 
>       output_buffer = oiio.ImageBuf(oiio.ImageSpec (width, height, 
> framebuffer_channels, format))
> 
>       # resize
>       if width == framebuffer_width and height == framebuffer_height:
>               output_buffer.copy(framebuffer, format)
>       else:
>               oiio.ImageBufAlgo.resize(output_buffer, framebuffer, filtername)
> 
>       # color convert
>       oiio.ImageBufAlgo.colorconvert(output_buffer, output_buffer, 
> working_colorspace, output_colorspace)
> 
>       # set dpx bitdepth
>       if destination.split('.')[-1].lower() == 'dpx':
>               output_buffer.specmod().attribute('oiio:BitsPerPixel', 10)
> 
>       # write
>       output_buffer.write(destination)
> 
> 
> <dpx_diff.png>
> 
> 
> 
> 
> <oiio_convert.py>_______________________________________________
> 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

Reply via email to