OpenImageIO
OpenImageIO copied to clipboard
version 2.1.11 very slowly vs 1.6.18
I merge big png files in one 15000x12000 in version 2.1.11 is very slowly than version 1.6.18. In version 2.1.11 merge time is 35 minutes and in version 1.6.18- 5 minutes.
I use Python version from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#openimageio
My example code:
images = list(map(oiio.ImageBuf, files))
new_im = oiio.ImageBuf()
new_im.copy(images[0])
if not vertical:
strip_size = int(images[0].spec().height/len(files))
else:
strip_size = int(images[0].spec().width/len(files))
t = 0
l = 0
for i in images:
i.specmod().x = 0
i.specmod().y = 0
cropped = oiio.ImageBuf()
if not vertical:
oiio.ImageBufAlgo.crop(cropped, i, oiio.ROI(0, images[0].spec().width,t , t+strip_size))
cropped.specmod().x = 0
cropped.specmod().y = 0
oiio.ImageBufAlgo.paste(new_im, 0, t, 0, 0, cropped)
else:
oiio.ImageBufAlgo.crop(cropped, i, oiio.ROI(t,t+strip_size,0, images[0].spec().height, ))
cropped.specmod().x = 0
cropped.specmod().y = 0
oiio.ImageBufAlgo.paste(new_im, t, 0, 0, 0, cropped)
l += 1
How many images are you starting with, and of what resolution? I want to try to reproduce this and understand why it's slow.
I have 20 images 15000x12000 each. I take 1/20 (750x12000) from each image.
The slowest part is:
oiio.ImageBufAlgo.crop(cropped, i, oiio.ROI(0, images[0].spec().width,t , t+strip_size))
I don't think you need to crop at all. It seems to me that you can use paste() to directly copy the subset of pixels you want from each source image into the final destination image.
Yes it's true. Now after the changes line with oiio.ImageBufAlgo.paste is slowl, but from the second image, because first is loading in new_im.copy(images[0])
I think loading the image into memory is slow.
I'm not sure why things seemed to slow down. That's a lot of versions to skip over, plus I'm not sure which versions of libpng you are using, build flag, etc.
I did some tests on my end with your script, and one thing I found is that it's 5x faster if I do it with TIFF files than with PNG. It does seem to be all I/O, and specific to PNG.