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')
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')
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
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
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)
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)
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)
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)