On Sat, 17 Oct 2020 at 18:17, Larry Gritz <[email protected]> wrote:
>
> Jan correctly points out that there is a version of
> read_scanlines/read_tiles/read_image that takes chbegin and chend
> arguments, which can be used to read just one channel (chbegin=c,
> chend=c+1), and so calling it once per channel, directing that channel to
> the appropriate single-channel buffer, is surprisingly efficient.
>
Good news!
> We also observe that in our OpenEXR reader, the implementation of
> read_scanlines/read_tiles where you ask for a single channel is ALREADY as
> efficient as it can get, since it requests only that one channel from the
> exr library, and as far as we know, incurs no unnecessary copies in the
> process.
>
This little python program seems to show some overhead (10-30%) depending
on whether or not I take the average or best run. Maybe I'm just seeing
numpy/python overhead though?
```
import time
import numpy # Import first, or you are measuring import time below!
import OpenImageIO
input = OpenImageIO.ImageInput.open(
"/home/john/dev/openexr-images/ScanLines/CandleGlass.exr" )
spec = input.spec()
t = time.time()
if False :
input.read_scanlines( spec.y, spec.y + spec.height, 0, 0,
spec.nchannels )
else :
for ch in range( 0, spec.nchannels ) :
input.read_scanlines( spec.y, spec.y + spec.height, 0, ch, ch + 1 )
print time.time() - t
```
John, I would be curious to hear if Gaffer is doing this the way that we
> now suspect is most efficient -- multiple calls requesting a single
> channel, rather than asking for all channels in a temp buffer and then
> descrambling yourself. We may already be very close to optimal efficiency,
> at least for some formats, and can do very focused changes to make other
> formats more efficient if needed.
>
We've been using the temp buffer approach. We actually have other shuffling
that we need to do (Gaffer's image processing is tile based, so we need to
shuffle the scanlines into tiles), but we'll definitely look into the
one-at-a-time approach. Because we assumed we needed to load RGBA together
for performance, we currently end up reading them all even when we may only
end up needing one channel, so there could be some memory savings for us
here in certain situations.
Thanks for looking in to this...
John
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org