Thanks for the reply. I am using OIIO_VER 2.1.11.2 (which is what we currently have installed at our studio - but I can update it if need be)
To clarify, the image I am cropping, the `scratch`, is a disk backed buffer. The original framebuffers from the renderer are processed to setup the spec for each image, and then one by one copied contiguously into the scratch with oiio_convert_image. The whole process iterates over the framebuffers one by one, setting up a spec for each image, and copying the data into the scratch. Once this is done, the data in the buffer is written to the image file on disk. Originally, the cropping method was as follows, here scratch is the image data stored as interleaved (first pixel of each image, second pixel of each image etc...): int offset_x = spec.x; int offset_y = spec.y; ImageBuf src("src", spec, scratch); // set spec roi to bbox calcuated earlier ROI roi (offset_x + bbox.x(), offset_x + bbox.x() + bbox.width(), offset_y + bbox.y(), offset_y + bbox.y() + bbox.height()); // crop ImageBuf full("full", spec); ImageBufAlgo::crop(full, src, roi); // save the framebuffer out to final destinationthanthe esan bool ok = full.write(filename.toStdString(), "exr"); Now with the multiimage support, unsigned int xoffset = 0; for (int s = 0; s < orig_fb_count; s++) { int offset_x = specs[s].x; int offset_y = specs[s].y; ImageBuf src("src", specs[s], scratch + xoffset); // set spec roi to bbox ROI roi (offset_x + bbox.x(), offset_x + bbox.x() + bbox.width(), offset_y + bbox.y(), offset_y + bbox.y() + bbox.height()); // crop ImageBuf full("full", specs[s]); ImageBufAlgo::crop(full, src, roi); //full.get_pixels(ROIroi, TypeDescformat, void *result if (s > 0) { // Not needed for the first, which is already open out->open (filename.toStdString(), full.spec(), ImageOutput::AppendSubimage); } out->write_image (TypeDesc::BASETYPE(full.spec().format.basetype), full.localpixels());); xoffset += specs[s].image_bytes(); } I've verified that ROI and the bbox contain the values I expect. If I skip the cropping and just write out the multi image like so (done in the same place in the code). if (s > 0) { // Not needed for the first, which is already open out->open (filename.toStdString(), specs[s], ImageOutput::AppendSubimage); } out->write_image (TypeDesc::BASETYPE(specs[s].format.basetype), scratch + xoffset); The image comes out fine. > And you are trying to crop each subimage to the same ROI? Yes, each loop iteration has the same values for bbox, and iterates over the specs (setup earlier) and the image data in scratch. Should I perhaps be cropping each image differently? The bbox is calculated as the sum of the bounding boxes over each layer (I realise this isn't entirely correct and should be calculated per image in this case though) It'd be hard to make a cut down version of this code unfortunately. --------------------------------------------------------------------------------------------- From: Larry Gritz <l...@larrygritz.com> To: OpenImageIO developers <oiio-dev@lists.openimageio.org> Subject: Re: [Oiio-dev] Multi image and cropping Message-ID: <b97e54d4-cae9-47c2-805a-e19fa71ea...@larrygritz.com> Content-Type: text/plain; charset="utf-8" So... the source image that you are cropping... is it starting out as a single multi-part exr (each "part" being what we call a "subimage")? And you are trying to crop each subimage to the same ROI? I feel like the crucial bits might be right before or after the quoted code. Do you think you could boil it down to a complete program (or function) that shows all the steps you are performing, that I can try on this end? Also, you don't say what version of OIIO you are using. I want to make sure you aren't bumping into some long-ago-fixed bug. -- lg SVEN STEINBAUER Senior R&D Engineer T +44 20 7287 4041 THE MILL 11-14 WINDMILL STREET, LONDON, W1T 2JG FOLLOW @MILLCHANNEL | FACEBOOK | TWITTER | INSTAGRAM|THEMILL.COM
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org