write(b, "invert.tif", oiio.UINT8) # pow b = ImageBufAlgo.pow(gray128, 2) write(b, "cpow1.exr") b = ImageBufAlgo.pow(gray128, (2, 2, 1)) write(b, "cpow2.exr") # channel_sum b = ImageBufAlgo.channel_sum( ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/tahoe-small.tif"), (.2126, .7152, .0722)) write(b, "chsum.tif", oiio.UINT8) # color_map b = ImageBufAlgo.color_map(tahoetiny, -1, "inferno") write(b, "colormap-inferno.tif", oiio.UINT8) b = ImageBufAlgo.color_map(tahoetiny, -1, 3, 3, (.25, .25, .25, 0, .5, 0, 1, 0, 0)) write(b, "colormap-custom.tif", oiio.UINT8) # premult/unpremult b = make_constimage(100, 100, 4, oiio.FLOAT, (.1, .1, .1, 1)) ImageBufAlgo.fill(b, (.2, .2, .2, .5), oiio.ROI(50, 80, 50, 80)) b = ImageBufAlgo.unpremult(b) write(b, "unpremult.tif") b = ImageBufAlgo.premult(b) write(b, "premult.tif") b = ImageBufAlgo.contrast_remap(tahoetiny, black=0.1, white=0.75) write(b, "contrast-stretch.tif")
b = ImageBuf() ImageBufAlgo.pow(b, gray128, 2) write(b, "cpow1.exr") b = ImageBuf() ImageBufAlgo.pow(b, gray128, (2, 2, 1)) write(b, "cpow2.exr") # channel_sum b = ImageBuf() ImageBufAlgo.channel_sum(b, ImageBuf("../oiiotool/src/tahoe-small.tif"), (.2126, .7152, .0722)) write(b, "chsum.tif", oiio.UINT8) # color_map b = ImageBuf() ImageBufAlgo.color_map(b, ImageBuf("../oiiotool/src/tahoe-tiny.tif"), -1, "inferno") write(b, "colormap-inferno.tif", oiio.UINT8) b = ImageBuf() ImageBufAlgo.color_map(b, ImageBuf("../oiiotool/src/tahoe-tiny.tif"), -1, 3, 3, (.25, .25, .25, 0, .5, 0, 1, 0, 0)) write(b, "colormap-custom.tif", oiio.UINT8) # premult/unpremult b = make_constimage(100, 100, 4, oiio.FLOAT, (.1, .1, .1, 1)) ImageBufAlgo.fill(b, (.2, .2, .2, .5), oiio.ROI(50, 80, 50, 80)) ImageBufAlgo.unpremult(b, b) write(b, "unpremult.tif") ImageBufAlgo.premult(b, b) write(b, "premult.tif") b = ImageBuf("../oiiotool/src/tahoe-small.tif")
b = ImageBufAlgo.invert (a) write (b, "invert.tif", oiio.UINT8) # pow b = ImageBufAlgo.pow (gray128, 2) write (b, "cpow1.exr") b = ImageBufAlgo.pow (gray128, (2,2,1)) write (b, "cpow2.exr") # channel_sum b = ImageBufAlgo.channel_sum (ImageBuf("../oiiotool/src/tahoe-small.tif"), (.2126,.7152,.0722)) write (b, "chsum.tif", oiio.UINT8) # color_map b = ImageBufAlgo.color_map (tahoetiny, -1, "inferno") write (b, "colormap-inferno.tif", oiio.UINT8) b = ImageBufAlgo.color_map (tahoetiny, -1, 3, 3, (.25,.25,.25,0,.5,0,1,0,0)) write (b, "colormap-custom.tif", oiio.UINT8) # premult/unpremult b = make_constimage(100,100,4,oiio.FLOAT,(.1,.1,.1,1)) ImageBufAlgo.fill (b, (.2,.2,.2,.5), oiio.ROI(50,80,50,80)) b = ImageBufAlgo.unpremult (b) write (b, "unpremult.tif") b = ImageBufAlgo.premult (b) write (b, "premult.tif") b = ImageBufAlgo.contrast_remap (tahoetiny, black=0.1, white=0.75) write (b, "contrast-stretch.tif") b = ImageBufAlgo.contrast_remap (tahoetiny, min=0.1, max=0.75)
b = ImageBuf() ImageBufAlgo.pow (b, gray128, 2) write (b, "cpow1.exr") b = ImageBuf() ImageBufAlgo.pow (b, gray128, (2,2,1)) write (b, "cpow2.exr") # channel_sum b = ImageBuf() ImageBufAlgo.channel_sum (b, ImageBuf("../oiiotool/src/tahoe-small.tif"), (.2126,.7152,.0722)) write (b, "chsum.tif", oiio.UINT8) # color_map b = ImageBuf() ImageBufAlgo.color_map (b, ImageBuf("../oiiotool/src/tahoe-tiny.tif"), -1, "spectrum") write (b, "colormap-spectrum.tif", oiio.UINT8) b = ImageBuf() ImageBufAlgo.color_map (b, ImageBuf("../oiiotool/src/tahoe-tiny.tif"), -1, 3, 3, (.25,.25,.25,0,.5,0,1,0,0)) write (b, "colormap-custom.tif", oiio.UINT8) # premult/unpremult b = make_constimage(100,100,4,oiio.FLOAT,(.1,.1,.1,1)) ImageBufAlgo.fill (b, (.2,.2,.2,.5), oiio.ROI(50,80,50,80)) ImageBufAlgo.unpremult (b, b) write (b, "unpremult.tif") ImageBufAlgo.premult (b, b) write (b, "premult.tif") b = ImageBuf ("../oiiotool/src/tahoe-small.tif")
def compare(self, diff_image_location=None, blur=10, raise_exception=True): """Compare the two given images Args: diff_image_location (str): file path for difference image. Written only if there are failures blur (float): image blur to apply before comparing """ if not diff_image_location: diff_image_location = os.path.dirname(self._image_a_location) self.blur_images(blur) ImageBufAlgo.compare( self.image_a_buffer, self.image_b_buffer, self.fail_threshold, self.warn_threshold, self._compare_results, ) diff_buffer = self.create_diff_buffer() if self.debug: self.image_a_buffer.write( '{}/{}_debug{}'.format( diff_image_location, os.path.basename(self._image_a_location), self._file_ext, ) ) self.image_b_buffer.write( '{}/{}_debug{}'.format( diff_image_location, os.path.basename(self._image_b_location), self._file_ext, ) ) if self._compare_results.nfail > 0: ImageBufAlgo.color_map(diff_buffer, diff_buffer, -1, 'inferno') remap_buffer = ImageBuf() multiplier = 5 ImageBufAlgo.mul( remap_buffer, diff_buffer, (multiplier, multiplier, multiplier, 1.0), ) ImageBufAlgo.add(remap_buffer, self.image_a_buffer, remap_buffer) msg = report_msg.format( failures=self._compare_results.nfail, warn=self._compare_results.nwarn, meanerror=self._compare_results.meanerror, rmserror=self._compare_results.rms_error, psnr=self._compare_results.PSNR ) remap_buffer.write( '{}/{}-{}_diff{}'.format( diff_image_location, os.path.basename(self._image_a_location), os.path.basename(self._image_b_location), self._file_ext, ) ) self.image_a_buffer.write( '{}/{}_debug{}'.format( diff_image_location, '1_a', self._file_ext, ) ) self.image_b_buffer.write( '{}/{}_debug{}'.format( diff_image_location, '1_b', self._file_ext, ) ) if raise_exception: raise ImageDifferenceError(msg) else: print(msg)