Esempio n. 1
0
    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"
    print "  mean =", compresults.meanerror
    print "  rms  =", compresults.rms_error
    print "  PSNR =", compresults.PSNR
    print "  max  =", compresults.maxerror
    print "  max @", (compresults.maxx, compresults.maxy, compresults.maxz, compresults.maxc)
    print "  warns", compresults.nwarn, "fails", compresults.nfail
Esempio n. 2
0
    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)

    # FIXME - colorconvert, ociolook need tests
    print("\nTesting color conversions:")
    b = make_constimage(2, 2, 4, oiio.FLOAT, (0, 0, 0, 1))
    b.setpixel(1, 0, (.25, .25, .25, 1))
    b.setpixel(0, 1, (.5, .5, .5, 1))
    b.setpixel(1, 1, (1, 1, 1, 1))
    dumpimg(b, msg="linear src=")
    r = ImageBufAlgo.colorconvert(b, "Linear", "sRGB")
    dumpimg(r, msg="to srgb =")
    r = ImageBufAlgo.colorconvert(r, "sRGB", "Linear")
    dumpimg(r, msg="back to linear =")
    # Just to test, make a matrix that halves red, doubles green,
    # adds 0.1 to blue.
Esempio n. 3
0
    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)
    print "Comparison: of flip.tif and flop.tif"
    print "  mean =", compresults.meanerror
    print "  rms  =", compresults.rms_error
    print "  PSNR =", compresults.PSNR
    print "  max  =", compresults.maxerror
    print "  max @", (compresults.maxx, compresults.maxy, compresults.maxz,
    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)

    # FIXME - colorconvert, ociolook need tests

    # computePixelStats
    b = ImageBuf ("../oiiotool/src/tahoe-small.tif")
    stats = ImageBufAlgo.computePixelStats (b)
    print ("Stats for tahoe-small.tif:")
    print ("  min         = ", stats.min)
    print ("  max         = ", stats.max)
    print ("  avg         = ", stats.avg)
    print ("  stddev      = ", stats.stddev)
    print ("  nancount    = ", stats.nancount)
    print ("  infcount    = ", stats.infcount)
    print ("  finitecount = ", stats.finitecount)