I have some grayscale data in TIFF files, and need to do some custom image processing on it, as well as use routines from numpy/scipy which expects the input as bumpy.ndarrays.
So, I was thinking along these lines: buf = oiio.ImageBuf(input) old_pixels = buf.get_pixels_as_ndarray(oiio.UINT16) new_pixels = process(old_pixels) buf.set_pixels_from_ndarray(new_pixels, oiio.UINT16) buf.write_image(output) I can always loop and call "set_pixel" - though I don't think setpixel allows me to hand it UINT16 values. It appears to always want floats. --jono On Thu, Jun 4, 2015 at 11:53 PM Larry Gritz <[email protected]> wrote: > Um, yeah, there's a simple way to pull pixels out, but not an easy way to > insert them (other than one at a time). > > I can probably add something for you easily (essentially, set_pixels). But > before I do, can you explain what you're trying to do overall, just in case > there's some better API strategy already in there? > > > 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
