Jono, can you try https://github.com/OpenImageIO/oiio/pull/1179 and see if that
addresses the problem?
-- lg
On Jun 29, 2015, at 5:37 PM, Jonathan Gibbs <[email protected]> wrote:
> I should have seen this sooner, but it appears that set_pixels in python is
> hard-coded to expect TypeDesc::TypeFloat, where as get_pixels lets me get the
> values using any type I specify. Do you think it's a good idea to be
> symmetric here?
>
> (py_imagebuf.cpp line 362)
>
> My particular use case is 16-bit int data. It's probably OK to promote to
> float given the processing I'm doing, but wasn't going to do that without a
> need.
>
> The current get_pixels/set_pixels interface return a python array
> (array.array), which I'm converting to a numpy.ndarray without trouble. I
> think I'm copying the data. There may be some way to get numpy and array to
> share memory, I'm still figuring that out. I imagine most will want them as
> numpy ndarrays, but it is nice to not have OIIO dependent on NumPy.
>
> (For the python-ites:
>
> numpyPixels = numpy.asarray(arrayPixels).reshape((spec.width, spec.height))
>
> and
>
> arrayPixels = array.array('H', numpyPixels.flatten())
> )
>
> --jono
>
> PS: Either Google or Apply insist of changing "numpy" into "bumpy" every
> single time. Bumpy is a much better name for the library.
>
>
> On Mon, Jun 15, 2015 at 2:54 PM Larry Gritz <[email protected]> wrote:
> Jono, see this: https://github.com/OpenImageIO/oiio/pull/1167
>
> This adds a set_pixels (and in the Python binding, it takes either a tuple or
> a Python array). It's probably not super efficient (ick, there's an
> intermediate copy to a std::vector involved), but it's a start.
>
> I'm not experienced enough with numpy to know; how would you want the Python
> API to look to be most efficient for your purposes?
>
> -- lg
>
>
> On Jun 4, 2015, at 4:24 PM, Jonathan Gibbs <[email protected]> wrote:
>
>> Does anyone have a good/simple example of working with OIIO in python. I can
>> get at the raw pixels nicely enough with ImageBuf.get_pixels(), but it's not
>> clear the best way to get those pixels back into an ImageBuf for writing.
>> (There is no set_pixels.)
>>
>> As a side note, get_pixels returns a Python array, which I can convert
>> easily enough to a numpy.ndarray. Is there a better way to get from a
>> ImageBuf to a numpy.ndarray and back again in a reasonably efficient manner?
>>
>> --jono
>
>> _______________________________________________
>> 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
--
Larry Gritz
[email protected]
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org