def create_diff_buffer(self): """Create a difference image buffer from image_a and image_b Returns: ImageBuf: new difference image buffer """ diff_buffer = ImageBuf(self.image_a_buffer.spec()) ImageBufAlgo.sub(diff_buffer, self.image_a_buffer, self.image_b_buffer) ImageBufAlgo.abs(diff_buffer, diff_buffer) return diff_buffer
write(b, "add.exr") # sub b = ImageBuf() ImageBufAlgo.sub( b, make_constimage(64, 64, 3, oiio.HALF, (.1, .2, .3)), make_constimage(64, 64, 3, oiio.HALF, (.1, .1, .1), 20, 20)) write(b, "sub.exr") # Test --absdiff and --abs # First, make a test image that's 0.5 on the left, -0.5 on the right a = ImageBuf(ImageSpec(128, 128, 3, oiio.HALF)) ImageBufAlgo.fill(a, (0.5, 0.5, 0.5)) ImageBufAlgo.fill(a, (-0.25, -0.25, -0.25), oiio.ROI(0, 64, 0, 128)) b = ImageBuf() ImageBufAlgo.abs(b, a) write(b, "abs.exr", oiio.HALF) b = ImageBuf() ImageBufAlgo.absdiff(b, a, (0.2, 0.2, 0.2)) write(b, "absdiff.exr", oiio.HALF) a = ImageBuf() # mul b = ImageBuf() ImageBufAlgo.mul(b, gray128, 1.5) write(b, "cmul1.exr") b = ImageBuf() ImageBufAlgo.mul(b, gray128, (1.5, 1, 0.5)) write(b, "cmul2.exr") # FIXME -- image multiplication; it's not in testsuite/oiiotool either # b = ImageBuf()
make_constimage(64,64,3,oiio.HALF,(.1,.1,.1),20,20)) write (b, "add.exr") # sub b = ImageBuf() ImageBufAlgo.sub (b, make_constimage(64,64,3,oiio.HALF,(.1,.2,.3)), make_constimage(64,64,3,oiio.HALF,(.1,.1,.1),20,20)) write (b, "sub.exr") # Test --absdiff and --abs # First, make a test image that's 0.5 on the left, -0.5 on the right a = ImageBuf (ImageSpec(128,128,3,oiio.HALF)) ImageBufAlgo.fill (a, (0.5,0.5,0.5)) ImageBufAlgo.fill (a, (-0.25,-0.25,-0.25), oiio.ROI(0,64,0,128)) b = ImageBuf() ImageBufAlgo.abs (b, a) write (b, "abs.exr", oiio.HALF) b = ImageBuf() ImageBufAlgo.absdiff (b, a, (0.2,0.2,0.2)) write (b, "absdiff.exr", oiio.HALF) a = ImageBuf() # mul b = ImageBuf() ImageBufAlgo.mul (b, gray128, 1.5) write (b, "cmul1.exr") b = ImageBuf() ImageBufAlgo.mul (b, gray128, (1.5,1,0.5)) write (b, "cmul2.exr") b = ImageBuf() ImageBufAlgo.mul (b, make_constimage(64,64,3,oiio.HALF,(.5,.5,.5)),
make_constimage(64, 64, 3, oiio.HALF, (.1, .2, .3)), make_constimage(64, 64, 3, oiio.HALF, (.1, .1, .1), 20, 20)) write(b, "add.exr") # sub b = ImageBufAlgo.sub( make_constimage(64, 64, 3, oiio.HALF, (.1, .2, .3)), make_constimage(64, 64, 3, oiio.HALF, (.1, .1, .1), 20, 20)) write(b, "sub.exr") # Test --absdiff and --abs # First, make a test image that's 0.5 on the left, -0.5 on the right a = ImageBuf(ImageSpec(128, 128, 3, oiio.HALF)) ImageBufAlgo.fill(a, (0.5, 0.5, 0.5)) ImageBufAlgo.fill(a, (-0.25, -0.25, -0.25), oiio.ROI(0, 64, 0, 128)) b = ImageBufAlgo.abs(a) write(b, "abs.exr", oiio.HALF) b = ImageBufAlgo.absdiff(a, (0.2, 0.2, 0.2)) write(b, "absdiff.exr", oiio.HALF) a = ImageBuf() # mul b = ImageBufAlgo.mul(gray128, 1.5) write(b, "cmul1.exr") b = ImageBufAlgo.mul(gray128, (1.5, 1, 0.5)) write(b, "cmul2.exr") b = ImageBufAlgo.mul(make_constimage(64, 64, 3, oiio.HALF, (.5, .5, .5)), make_constimage(64, 64, 3, oiio.HALF, (1.5, 1, 0.5))) write(b, "mul.exr", oiio.HALF) # mad
write (b, "cadd2.exr") b = ImageBufAlgo.add (make_constimage(64,64,3,oiio.HALF,(.1,.2,.3)), make_constimage(64,64,3,oiio.HALF,(.1,.1,.1),20,20)) write (b, "add.exr") # sub b = ImageBufAlgo.sub (make_constimage(64,64,3,oiio.HALF,(.1,.2,.3)), make_constimage(64,64,3,oiio.HALF,(.1,.1,.1),20,20)) write (b, "sub.exr") # Test --absdiff and --abs # First, make a test image that's 0.5 on the left, -0.5 on the right a = ImageBuf (ImageSpec(128,128,3,oiio.HALF)) ImageBufAlgo.fill (a, (0.5,0.5,0.5)) ImageBufAlgo.fill (a, (-0.25,-0.25,-0.25), oiio.ROI(0,64,0,128)) b = ImageBufAlgo.abs (a) write (b, "abs.exr", oiio.HALF) b = ImageBufAlgo.absdiff (a, (0.2,0.2,0.2)) write (b, "absdiff.exr", oiio.HALF) a = ImageBuf() # mul b = ImageBufAlgo.mul (gray128, 1.5) write (b, "cmul1.exr") b = ImageBufAlgo.mul (gray128, (1.5,1,0.5)) write (b, "cmul2.exr") b = ImageBufAlgo.mul (make_constimage(64,64,3,oiio.HALF,(.5,.5,.5)), make_constimage(64,64,3,oiio.HALF,(1.5,1,0.5))) write (b, "mul.exr", oiio.HALF) # mad