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/tahoe-small.tif"), (0.2126, 0.7152, 0.0722)) write(b, "chsum.tif", oiio.UINT8) # premult/unpremult b = make_constimage(100, 100, 4, oiio.FLOAT, (0.1, 0.1, 0.1, 1)) ImageBufAlgo.fill(b, (0.2, 0.2, 0.2, 0.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/tahoe-small.tif") ImageBufAlgo.rangecompress(b, b) write(b, "rangecompress.tif", oiio.UINT8) ImageBufAlgo.rangeexpand(b, b) write(b, "rangeexpand.tif", oiio.UINT8) # FIXME - colorconvert, ociolook need tests # computePixelStats compresults = oiio.CompareResults() ImageBufAlgo.compare(ImageBuf("flip.tif"), ImageBuf("flop.tif"), 1.0e-6, 1.0e-6, compresults) print "Comparison: of flip.tif and flop.tif"
b = ImageBuf() ImageBufAlgo.pow(b, gray128, (2, 2, 1)) write(b, "cpow2.exr") # channel_sum b = ImageBuf() ImageBufAlgo.channel_sum(b, ImageBuf("../oiiotool/tahoe-small.tif"), (.2126, .7152, .0722)) write(b, "chsum.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/tahoe-small.tif") ImageBufAlgo.rangecompress(b, b) write(b, "rangecompress.tif", oiio.UINT8) ImageBufAlgo.rangeexpand(b, b) write(b, "rangeexpand.tif", oiio.UINT8) # FIXME - colorconvert, ociolook need tests # computePixelStats compresults = oiio.CompareResults() ImageBufAlgo.compare(ImageBuf("flip.tif"), ImageBuf("flop.tif"), 1.0e-6, 1.0e-6, compresults)
def premultiply_image(cls, img_pixels: np.array) -> np.array: """ Premultiply a numpy image with itself """ a = cls.np_to_imagebuf(img_pixels) ImageBufAlgo.premult(a, a) return a.get_pixels(a.spec().format, a.spec().roi_full)
(.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) write(b, "contrast-shrink.tif") b = ImageBufAlgo.contrast_remap(tahoetiny, scontrast=5.0) write(b, "contrast-sigmoid5.tif") b = ImageBuf(OIIO_TESTSUITE_ROOT + "/oiiotool/src/tahoe-small.tif") b = ImageBufAlgo.rangecompress(b) write(b, "rangecompress.tif", oiio.UINT8) b = ImageBufAlgo.rangeexpand(b) write(b, "rangeexpand.tif", oiio.UINT8)
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) write (b, "contrast-shrink.tif") b = ImageBufAlgo.contrast_remap (tahoetiny, scontrast=5.0) write (b, "contrast-sigmoid5.tif") b = ImageBuf ("../oiiotool/src/tahoe-small.tif") b = ImageBufAlgo.rangecompress (b) write (b, "rangecompress.tif", oiio.UINT8) b = ImageBufAlgo.rangeexpand (b) write (b, "rangeexpand.tif", oiio.UINT8)