def ImageBufReorient(imageBuf, orientation): ''' Resets the orientation of the image ''' ''' Orientation 6 and 8 seem to be reversed in OIIO, at least for Canon cameras... This needs to be investigated further. ''' if orientation == 6: imageBuf.specmod().attribute("Orientation", 1) ImageBufAlgo.rotate270(imageBuf, imageBuf) ImageBufAlgo.reorient(imageBuf, imageBuf) elif orientation == 8: imageBuf.specmod().attribute("Orientation", 1) ImageBufAlgo.rotate90(imageBuf, imageBuf) ImageBufAlgo.reorient(imageBuf, imageBuf) else: ImageBufAlgo.reorient(imageBuf, imageBuf)
def ImageBufReorient(imageBuf, orientation): ''' Resets the orientation of the image ''' ''' Orientation 6 and 8 seem to be reversed in OIIO, at least for Canon cameras... This needs to be investigated further. ''' if orientation == 6: imageBuf.specmod().attribute ("Orientation", 1) ImageBufAlgo.rotate90(imageBuf, imageBuf) ImageBufAlgo.reorient (imageBuf, imageBuf) elif orientation == 8: imageBuf.specmod().attribute ("Orientation", 1) ImageBufAlgo.rotate270(imageBuf, imageBuf) ImageBufAlgo.reorient (imageBuf, imageBuf) else: ImageBufAlgo.reorient (imageBuf, imageBuf)
b = ImageBuf() ImageBufAlgo.flop(b, ImageBuf("../oiiotool/image.tif")) write(b, "flop.tif") # flipflop b = ImageBuf() ImageBufAlgo.flipflop(b, ImageBuf("../oiiotool/image.tif")) write(b, "flipflop.tif") # reorient b = ImageBuf() image_small = ImageBuf() ImageBufAlgo.resample(image_small, ImageBuf("../oiiotool/image.tif"), roi=oiio.ROI(0, 160, 0, 120)) ImageBufAlgo.rotate90(image_small, image_small) image_small.specmod().attribute("Orientation", 8) ImageBufAlgo.reorient(b, image_small) write(b, "reorient1.tif") image_small = ImageBuf() # transpose b = ImageBuf() ImageBufAlgo.transpose(b, ImageBuf("../oiiotool/image.tif")) write(b, "transpose.tif") # circular_shift b = ImageBuf() ImageBufAlgo.circular_shift(b, ImageBuf("../oiiotool/image.tif"), 100, 50) write(b, "cshift.tif") # clamp b = ImageBuf()
write(b, "flop.tif") # flipflop b = ImageBuf() ImageBufAlgo.flipflop(b, ImageBuf("../oiiotool/image.tif")) write(b, "flipflop.tif") # reorient b = ImageBuf() image_small = ImageBuf() ImageBufAlgo.resample(image_small, ImageBuf("../oiiotool/image.tif"), roi=oiio.ROI(0, 160, 0, 120)) ImageBufAlgo.rotate90(image_small, image_small) image_small.specmod().attribute("Orientation", 8) ImageBufAlgo.reorient(b, image_small) write(b, "reorient1.tif") image_small = ImageBuf() # transpose b = ImageBuf() ImageBufAlgo.transpose(b, ImageBuf("../oiiotool/image.tif")) write(b, "transpose.tif") # circular_shift b = ImageBuf() ImageBufAlgo.circular_shift(b, ImageBuf("../oiiotool/image.tif"), 100, 50) write(b, "cshift.tif") # clamp b = ImageBuf()
write(b, "flip.tif") # flop b = ImageBufAlgo.flop( ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/image.tif")) write(b, "flop.tif") # reorient image_small = ImageBuf() ImageBufAlgo.resample(image_small, ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/image.tif"), roi=oiio.ROI(0, 160, 0, 120)) image_small = ImageBufAlgo.rotate90(image_small) image_small.specmod().attribute("Orientation", 8) b = ImageBufAlgo.reorient(image_small) write(b, "reorient1.tif") image_small = ImageBuf() # transpose b = ImageBufAlgo.transpose( ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/image.tif")) write(b, "transpose.tif") # circular_shift b = ImageBufAlgo.circular_shift( ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/image.tif"), 100, 50) write(b, "cshift.tif") # clamp b = ImageBufAlgo.resize(grid, roi=oiio.ROI(0, 500, 0, 500))
write (b, "rotate270.tif") # flip b = ImageBufAlgo.flip (ImageBuf("../oiiotool/src/image.tif")) write (b, "flip.tif") # flop b = ImageBufAlgo.flop (ImageBuf("../oiiotool/src/image.tif")) write (b, "flop.tif") # reorient image_small = ImageBuf() ImageBufAlgo.resample (image_small, ImageBuf("../oiiotool/src/image.tif"), roi=oiio.ROI(0,160,0,120)) image_small = ImageBufAlgo.rotate90 (image_small) image_small.specmod().attribute ("Orientation", 8) b = ImageBufAlgo.reorient (image_small) write (b, "reorient1.tif") image_small = ImageBuf() # transpose b = ImageBufAlgo.transpose (ImageBuf("../oiiotool/src/image.tif")) write (b, "transpose.tif") # circular_shift b = ImageBufAlgo.circular_shift (ImageBuf("../oiiotool/src/image.tif"), 100, 50) write (b, "cshift.tif") # clamp b = ImageBufAlgo.resize (grid, roi=oiio.ROI(0,500,0,500)) b = ImageBufAlgo.clamp (b, (0.2,0.2,0.2,0.2), (100,100,0.5,1)) write (b, "grid-clamped.tif", oiio.UINT8)