Exemple #1
0
def ImageBufWeight(weight, inputBuffer, gamma=0.75, clip=0.05, lut=None):
    '''
    Apply a bell / triangular weight function to an Image Buffer
    '''
    (channelType, width, height, channels, orientation, metadata,
     inputSpec) = ImageAttributes(inputBuffer)

    temp = ImageBufMakeConstant(width, height, channels, oiio.HALF)
    grey05 = ImageBufMakeConstant(width, height, channels, oiio.HALF,
                                  tuple([0.5] * channels))

    if lut:
        ImageBufAlgo.add(temp, temp, inputBuffer)
        if 1 in lut:
            ImageBufAlgo.clamp(temp, temp, tuple([0.5] * channels),
                               tuple([1.0] * channels))

        if 2 in lut:
            ImageBufAlgo.clamp(temp, temp, tuple([0.0] * channels),
                               tuple([0.5] * channels))

        #print( "\tLUT application : %s" % result )
        ImageBufAlgo.absdiff(temp, grey05, temp)
    else:
        ImageBufAlgo.absdiff(temp, grey05, inputBuffer)

    ImageBufAlgo.sub(temp, grey05, temp)
    ImageBufAlgo.div(temp, temp, 0.5)

    ImageBufAlgo.sub(temp, temp, clip)
    ImageBufAlgo.mul(temp, temp, 1.0 / (1.0 - clip))

    ImageBufAlgo.clamp(temp, temp, tuple([0.0] * channels),
                       tuple([1.0] * channels))
    ImageBufAlgo.pow(weight, temp, gamma)
Exemple #2
0
def ImageBufWeight(weight, inputBuffer, gamma=0.75, clip=0.05, lut=None):
    '''
    Apply a bell / triangular weight function to an Image Buffer
    '''
    (channelType, width, height, channels, orientation, metadata, inputSpec) = ImageAttributes(inputBuffer)
    
    temp     = ImageBufMakeConstant(width, height, channels, oiio.HALF )
    grey05   = ImageBufMakeConstant(width, height, channels, oiio.HALF, tuple([0.5]*channels) )
    
    if lut:
        ImageBufAlgo.add(temp, temp, inputBuffer)
        if 1 in lut:
            ImageBufAlgo.clamp(temp, temp, tuple([0.5]*channels), tuple([1.0]*channels))

        if 2 in lut:
            ImageBufAlgo.clamp(temp, temp, tuple([0.0]*channels), tuple([0.5]*channels))

        #print( "\tLUT application : %s" % result )
        ImageBufAlgo.absdiff(temp, grey05, temp)
    else:
        ImageBufAlgo.absdiff(temp, grey05, inputBuffer)
    
    ImageBufAlgo.sub(temp, grey05, temp)
    ImageBufAlgo.div(temp, temp, 0.5)

    ImageBufAlgo.sub(temp, temp, clip)
    ImageBufAlgo.mul(temp, temp, 1.0/(1.0-clip))

    ImageBufAlgo.clamp(temp, temp, tuple([0.0]*channels), tuple([1.0]*channels))
    ImageBufAlgo.pow(weight, temp, gamma)
Exemple #3
0
    image_small = ImageBuf()

    # transpose
    b = ImageBuf()
    ImageBufAlgo.transpose(b, ImageBuf("../oiiotool/image.tif"))
    write(b, "transpose.tif")

    # circular_shift
    b = ImageBuf()
    ImageBufAlgo.circular_shift(b, ImageBuf("../oiiotool/image.tif"), 100, 50)
    write(b, "cshift.tif")

    # clamp
    b = ImageBuf()
    ImageBufAlgo.resize(b, grid, roi=oiio.ROI(0, 500, 0, 500))
    ImageBufAlgo.clamp(b, b, (0.2, 0.2, 0.2, 0.2), (100, 100, 0.5, 1))
    write(b, "grid-clamped.tif", oiio.UINT8)

    # add
    b = ImageBuf()
    ImageBufAlgo.add(b, gray128, 0.25)
    write(b, "cadd1.exr")
    b = ImageBuf()
    ImageBufAlgo.add(b, gray128, (0, 0.25, -0.25))
    write(b, "cadd2.exr")
    b = ImageBuf()
    ImageBufAlgo.add(
        b,
        make_constimage(64, 64, 3, oiio.HALF, (0.1, 0.2, 0.3)),
        make_constimage(64, 64, 3, oiio.HALF, (0.1, 0.1, 0.1), 20, 20),
    )
Exemple #4
0
    image_small = ImageBuf()

    # transpose
    b = ImageBuf()
    ImageBufAlgo.transpose(b, ImageBuf("../oiiotool/image.tif"))
    write(b, "transpose.tif")

    # circular_shift
    b = ImageBuf()
    ImageBufAlgo.circular_shift(b, ImageBuf("../oiiotool/image.tif"), 100, 50)
    write(b, "cshift.tif")

    # clamp
    b = ImageBuf()
    ImageBufAlgo.resize(b, grid, roi=oiio.ROI(0, 500, 0, 500))
    ImageBufAlgo.clamp(b, b, (0.2, 0.2, 0.2, 0.2), (100, 100, 0.5, 1))
    write(b, "grid-clamped.tif", oiio.UINT8)

    # add
    b = ImageBuf()
    ImageBufAlgo.add(b, gray128, 0.25)
    write(b, "cadd1.exr")
    b = ImageBuf()
    ImageBufAlgo.add(b, gray128, (0, 0.25, -0.25))
    write(b, "cadd2.exr")
    b = ImageBuf()
    ImageBufAlgo.add(
        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, "add.exr")