Exemplo n.º 1
0
def goRangeFunctions():
    xmin, xmax, sigma = -3.5, 3.5, 1.0
    nx = 351
    dx = (xmax - xmin) / (nx - 1)
    fx = xmin
    sx = Sampling(nx, dx, fx)
    yg = BilateralFilter.sampleRangeFunction(gauss, sigma, sx)
    yt = BilateralFilter.sampleRangeFunction(tukey, sigma, sx)
    #yh = BilateralFilter.sampleRangeFunction(huber,sigma,sx)
    #x = rampfloat(fx,dx,nx)
    #yg = mul(x,yg)
    #yh = mul(x,yh)
    #yt = mul(x,yt)
    sp = SimplePlot()
    sp.setBackground(backgroundColor)
    sp.setFontSizeForSlide(1.0, 0.9)
    sp.setSize(700, 500)
    sp.setHLabel(" ")
    sp.setVLabel(" ")
    solid = PointsView.Line.SOLID
    dash = PointsView.Line.DASH
    dot = PointsView.Line.DOT
    #pv = sp.addPoints(sx,yh); pv.setLineStyle(dot); pv.setLineWidth(4)
    pv = sp.addPoints(sx, yg)
    pv.setLineStyle(dash)
    pv.setLineWidth(4)
    pv = sp.addPoints(sx, yt)
    pv.setLineStyle(solid)
    pv.setLineWidth(4)
    if pngDir:
        sp.paintToPng(720, 3.3, pngDir + "blftg.png")
Exemplo n.º 2
0
def goRangeFunctions():
  xmin,xmax,sigma = -3.5,3.5,1.0
  nx = 351
  dx = (xmax-xmin)/(nx-1)
  fx = xmin
  sx = Sampling(nx,dx,fx)
  yg = BilateralFilter.sampleRangeFunction(gauss,sigma,sx)
  yt = BilateralFilter.sampleRangeFunction(tukey,sigma,sx)
  #yh = BilateralFilter.sampleRangeFunction(huber,sigma,sx)
  #x = rampfloat(fx,dx,nx)
  #yg = mul(x,yg)
  #yh = mul(x,yh)
  #yt = mul(x,yt)
  sp = SimplePlot()
  sp.setBackground(backgroundColor)
  sp.setFontSizeForSlide(1.0,0.9)
  sp.setSize(700,500)
  sp.setHLabel(" ")
  sp.setVLabel(" ")
  solid = PointsView.Line.SOLID
  dash = PointsView.Line.DASH
  dot = PointsView.Line.DOT
  #pv = sp.addPoints(sx,yh); pv.setLineStyle(dot); pv.setLineWidth(4)
  pv = sp.addPoints(sx,yg); pv.setLineStyle(dash); pv.setLineWidth(4)
  pv = sp.addPoints(sx,yt); pv.setLineStyle(solid); pv.setLineWidth(4)
  if pngDir:
    sp.paintToPng(720,3.3,pngDir+"blftg.png")
Exemplo n.º 3
0
def goApproximation():
    factor = 0.67448  # 3rd quartile of standard normal distribution (sigma = 1)
    sigma = 1.401114
    pmin, pmax = -9.0, 9.0
    np, dp, fp = 301, 0.06, pmin
    nk, dk, fk = 13, 1.5, pmin
    sp = Sampling(np, dp, fp)
    sk = Sampling(nk, dk, fk)
    type = BilateralFilter.Type.GAUSS
    rf = BilateralFilter.sampleRangeFunction(type, sigma, sp)
    rg = BilateralFilter.sampleRangeFunction(type, sigma / sqrt(2.0), sp)
    method = CubicInterpolator.Method.MONOTONIC
    rfi = CubicInterpolator(method, np, rampfloat(fp, dp, np), rf)
    rgi = CubicInterpolator(method, np, rampfloat(fp, dp, np), rg)
    rr = zerofloat(np, np)
    ra = zerofloat(np, np)
    r0 = zerofloat(np, np)
    rh = zerofloat(np, np)
    for i in range(np):
        pi = sp.getValue(i)
        for j in range(np):
            pj = sp.getValue(j)
            rr[i][j] = rfi.interpolate(pi - pj)
            for k in range(nk):
                pk = sk.getValue(k)
                rjk = rgi.interpolate(pj - pk)
                rik = rgi.interpolate(pi - pk)
                #hik = hat(dk,pi-pk)
                #ra[i][j] += hik*rjk
                ra[i][j] += rik * rjk
                if k == nk / 2:
                    r0[i][j] = rjk
                    rh[i][j] = rik * rjk
                    #rh[i][j] = hik*rjk
    rr = div(rr, max(rr))
    r0 = div(r0, max(r0))
    rh = div(rh, max(rh))
    ra = div(ra, max(ra))
    plotR2(sp, rr, "blfrr")
    plotR2(sp, r0, "blfr0")
    plotR2(sp, rh, "blfrh")
    plotR2(sp, ra, "blfra")
Exemplo n.º 4
0
def goApproximation():
  factor = 0.67448 # 3rd quartile of standard normal distribution (sigma = 1)
  sigma = 1.401114
  pmin,pmax = -9.0,9.0
  np,dp,fp = 301,0.06,pmin
  nk,dk,fk =  13,1.5,pmin
  sp = Sampling(np,dp,fp)
  sk = Sampling(nk,dk,fk)
  type = BilateralFilter.Type.GAUSS
  rf = BilateralFilter.sampleRangeFunction(type,sigma,sp)
  rg = BilateralFilter.sampleRangeFunction(type,sigma/sqrt(2.0),sp)
  method = CubicInterpolator.Method.MONOTONIC
  rfi = CubicInterpolator(method,np,rampfloat(fp,dp,np),rf)
  rgi = CubicInterpolator(method,np,rampfloat(fp,dp,np),rg)
  rr = zerofloat(np,np)
  ra = zerofloat(np,np)
  r0 = zerofloat(np,np)
  rh = zerofloat(np,np)
  for i in range(np):
    pi = sp.getValue(i)
    for j in range(np):
      pj = sp.getValue(j)
      rr[i][j] = rfi.interpolate(pi-pj)
      for k in range(nk):
        pk = sk.getValue(k)
        rjk = rgi.interpolate(pj-pk)
        rik = rgi.interpolate(pi-pk)
        #hik = hat(dk,pi-pk)
        #ra[i][j] += hik*rjk
        ra[i][j] += rik*rjk
        if k==nk/2:
          r0[i][j] = rjk
          rh[i][j] = rik*rjk
          #rh[i][j] = hik*rjk
  rr = div(rr,max(rr))
  r0 = div(r0,max(r0))
  rh = div(rh,max(rh))
  ra = div(ra,max(ra))
  plotR2(sp,rr,"blfrr")
  plotR2(sp,r0,"blfr0")
  plotR2(sp,rh,"blfrh")
  plotR2(sp,ra,"blfra")