Example #1
0
File: vg.py Project: zfbi/lss
def goBilateral(f):
    g = like(f)
    sigmaS = 24.0  # spatial filter sigma
    sigmaR = computeSigmaR(f)
    blf = BilateralFilter(sigmaS, sigmaR)
    blf.apply(f, g)
    plot(g, cmin=-1, cmax=1, name='bilateral filter')
Example #2
0
def bilateralFilterQC(sigmaS, sigmaX, t, x):
    y = like(x)
    bf = BilateralFilter(sigmaS, sigmaX)
    if t:
        qc = bf.applyQC(t, x, y)
    else:
        qc = bf.applyQC(x, y)
    return qc.sx, qc.sn, qc.sd, qc.tn, qc.td
Example #3
0
def bilateralFilter(sigmaS, sigmaX, t, x):
    y = like(x)
    bf = BilateralFilter(sigmaS, sigmaX)
    if t:
        bf.apply(t, x, y)
    else:
        bf.apply(x, y)
    return y
Example #4
0
def goFilterImpulses():
    xa, s1, s2, clip = getImage()
    xb = makeImpulses(12, len(xa[0]), len(xa))
    t = diffusionTensors(2.0, xa)
    plot(xa, s1, s2, 1.3)
    #plot(xb,s1,s2,0.9)
    for sigmaR in [0.1, 1.0, 100.0]:
        #for sigmaR in [100.0]:
        y = like(xa)
        bf = BilateralFilter(30.0, sigmaR)
        bf.setType(BilateralFilter.Type.TUKEY)
        bf.applyAB(t, xa, xb, y)
        y = smoothS(y)
        #plot(y,s1,s2,0.5*max(y))
        plot(y, s1, s2, 0.1)
Example #5
0
def goFilterRandom():
    xa, s1, s2, clip = getImage()
    plot(xa, s1, s2, clip)
    n1, n2 = len(xa[0]), len(xa)
    xb = makeRandom(n1, n2)
    t = diffusionTensors(2.0, xa)
    #plot(xa,s1,s2,1.3)
    #plot(xb,s1,s2,0.5)
    xqqd = qqd(x)
    for sigmaR in [xqqd, 100 * xqqd]:
        y = like(xa)
        bf = BilateralFilter(30.0, sigmaR)
        bf.setType(BilateralFilter.Type.TUKEY)
        bf.applyAB(t, xa, xb, y)
        plot(y, s1, s2, 0.1)
        bf.apply(t, xa, y)
        plot(y, s1, s2, clip)
Example #6
0
def goRandomBlocks():
    n1 = 801
    x = makeBlocks(n1)
    plotB(x, x, -12, 12, "rbx")
    return
    y = add(x, makeNoiseForBlocks(3141, 8.0, 3.0, n1))
    plotB(x, y, -12, 12, "rbxy")
    sigmaS = 20.0
    yqqd = qqd(y)
    z = zerofloat(n1)
    for scale in [0.01, 0.5, 1.0, 1.5, 10, 100.0]:
        sigmaX = scale * yqqd
        print "sigmaS =", sigmaS, " sigmaX =", sigmaX
        bf = BilateralFilter(sigmaS, sigmaX)
        bf.setType(BilateralFilter.Type.TUKEY)
        bf.apply(y, z)
        png = "rbxz" + str(int(scale * 10 + 0.5))
        if len(png) == 1: png = "0" + png
        plotB(x, z, -12, 12, png=png)