I've been using numpy from oiio reads for a few years now and the main reason I prefer it is the datatype flexibility (half floats are supported natively for one thing). So that was my main reason to use it (I'm converting all oiio reads to numpy across a lot of code at the moment)
In short I'm all for it as long as long as numpy isn't changing so drastically all the time that we're all forced to manage older/newer versions without being ready to adopt them on a large scale. I'd probably prefer multidimensional as well, considering if I ever needed a flat view numpy should be able to give that to me either through a view or a copy if needed. Right now I'm computing a lot of strides based on pixel byte size per channel/pixel which might be able to go away if I had a multi dimensional view. Just my two cents as well. ~Andrew On Wed, Nov 1, 2017 at 11:57 AM, Jonathan Tilden (2K) < [email protected]> wrote: > On one hand, I’m not a huge fan of having the python bindings depend on > another library (even though we use numpy extensively). I rather like that > its self contained once all compiled. > > > > Using the older python arrays, you can simply do the following to > efficiently get it into a numpy array: > > > > pixels = np.frombuffer(imginput.read_image(0, 3, oiio.FLOAT), dtype='f') > > > > Similarly you can convert it back into a regular array to imageout with > the following: > > pixels.astype('f', copy=False).data > > > > > > On the other hand, it would be convenient to not have to read pixels > through a wrapper function, but directly in the API. If that were the > route, I would prefer the multidimensional array. > > > > My 2 cents, > > -J > > > > > > *From:* Oiio-dev [mailto:[email protected]] *On > Behalf Of *Larry Gritz > *Sent:* Wednesday, November 1, 2017 11:09 AM > *To:* OpenImageIO dev list <[email protected]> > *Subject:* [Oiio-dev] Python bindings question > > > > Last weekend I started to tinker with pybind11 (https://github.com/pybind/ > pybind11), which is very similar to Boost.Python, but header-only, > allegedly builds MUCH faster, and by starting with C++11 as a baseline, its > use and implementation are a lot simpler. > > I got partially done with converting the oiio python bindings to it, and > am liking the direction it was going, so I'll probably finish it. But an > issue has come up that I'm seeking feedback on. > > For actual blocks of pixels, like the results of ImageInput.read_image(), > it seems that it's a lot more straightforward to pass back and forth NumPy > arrays rather than old style python arrays. So... > > 1. Does anybody object to that? Is NumPy already deep enough in your > Python practice that you would accept (and maybe prefer) switching to > directly using numpy arrays to pass image data around? > > 2. If so, would you prefer that it hand you a true multidimensional array > organized like [y][x][channel]? Or would you rather just get a flat 1D > array with all the values, and you can cast it to the array shape that you > prefer? > > -- > 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 > >
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
