示例#1
0
    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.
    M = (0.5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0.1, 1)
    r = ImageBufAlgo.colormatrixtransform(b, M)
    dumpimg(r, msg="after *M =")

    # computePixelStats
    b = ImageBuf(OIIO_TESTSUITE_ROOT + "/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)

    compresults = ImageBufAlgo.compare(ImageBuf("flip.tif"),
                                       ImageBuf("flop.tif"), 1.0e-6, 1.0e-6)
    print("Comparison: of flip.tif and flop.tif")
    print("  mean = %.5g" % compresults.meanerror)
    print("  rms  = %.5g" % compresults.rms_error)
    print("  PSNR = %.5g" % compresults.PSNR)
示例#2
0
    write (b, "unpremult.tif")
    ImageBufAlgo.premult (b, b)
    write (b, "premult.tif")

    b = ImageBuf ("../oiiotool/src/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
    b = ImageBuf ("../oiiotool/src/tahoe-small.tif")
    stats = oiio.PixelStats()
    ImageBufAlgo.computePixelStats (b, stats)
    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

    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 = %.5g" % compresults.meanerror
    print "  rms  = %.5g" % compresults.rms_error
示例#3
0
    write(b, "unpremult.tif")
    ImageBufAlgo.premult(b, b)
    write(b, "premult.tif")

    b = ImageBuf("../oiiotool/src/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
    b = ImageBuf("../oiiotool/src/tahoe-small.tif")
    stats = oiio.PixelStats()
    ImageBufAlgo.computePixelStats(b, stats)
    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)

    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 = %.5g" % compresults.meanerror)
    print("  rms  = %.5g" % compresults.rms_error)
    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)

    compresults = ImageBufAlgo.compare (ImageBuf("flip.tif"), ImageBuf("flop.tif"),
                                        1.0e-6, 1.0e-6)
    print ("Comparison: of flip.tif and flop.tif")
    print ("  mean = %.5g" % compresults.meanerror)
    print ("  rms  = %.5g" % compresults.rms_error)
    print ("  PSNR = %.5g" % compresults.PSNR)