Пример #1
0
def goTest():
    f, g = getSinoImages()
    f = copy(ni, nx, f)
    g = copy(ni + nl, nx, g)
    SimplePlot.asPixels(f)
    SimplePlot.asPixels(g)
    mx = 4
    ht = 50
    #for mx in [1,5,10,20,40,80]:
    #for mx in [1,4,16,64]:
    for ht in [1, 25, 50, 100]:
        ixl = nx / 2 - mx / 2
        ixu = ixl + mx
        nj = 1 + (ni - 1) / ht
        i = rampint(0, ht, nj)
        e = zerofloat(nl, ni)
        for ix in range(ixl, ixu):
            ei = DynamicWarpingS.computeErrors(nl, f[ix], g[ix])
            add(ei, e, e)
        u1 = DynamicWarpingS.findShifts(0.0, 2.0, e)
        uj = DynamicWarpingS.findShiftsI(0.0, 2.0, e, i)
        tj = rampfloat(0.0, ht, nj)
        ti = rampfloat(0.0, 1.0, ni)
        ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC, tj, uj)
        u2 = ci.interpolate(ti)
        plotErrors(e)
        if ht > 1:
            plotErrors(e, None, u2, tj, uj)
        else:
            plotErrors(e, None, u2)
Пример #2
0
def goTest():
  f,g = getSinoImages()
  f = copy(ni,nx,f)
  g = copy(ni+nl,nx,g)
  SimplePlot.asPixels(f)
  SimplePlot.asPixels(g)
  mx = 4
  ht = 50
  #for mx in [1,5,10,20,40,80]:
  #for mx in [1,4,16,64]:
  for ht in [1,25,50,100]:
    ixl = nx/2-mx/2
    ixu = ixl+mx
    nj = 1+(ni-1)/ht
    i = rampint(0,ht,nj)
    e = zerofloat(nl,ni)
    for ix in range(ixl,ixu):
      ei = DynamicWarpingS.computeErrors(nl,f[ix],g[ix])
      add(ei,e,e)
    u1 = DynamicWarpingS.findShifts(0.0,2.0,e)
    uj = DynamicWarpingS.findShiftsI(0.0,2.0,e,i)
    tj = rampfloat(0.0,ht,nj)
    ti = rampfloat(0.0,1.0,ni)
    ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC,tj,uj)
    u2 = ci.interpolate(ti)
    plotErrors(e)
    if ht>1:
      plotErrors(e,None,u2,tj,uj)
    else:
      plotErrors(e,None,u2)
Пример #3
0
def goErrors():
    zoom = 0
    f, g = getSinoImages()
    f = copy(ni, nx, f)
    g = copy(ni + nl, nx, g)
    e = computeErrors(5, f, g)
    for ht in [1, 25, 50, 100]:
        nj = 1 + (ni - 1) / ht
        i = rampint(0, ht, nj)
        u1 = DynamicWarpingS.findShifts(0.0, 2.0, e)
        uj = DynamicWarpingS.findShiftsI(0.0, 2.0, e, i)
        tj = rampfloat(0.0, ht, nj)
        ti = rampfloat(0.0, 1.0, ni)
        ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC, tj, uj)
        u2 = ci.interpolate(ti)
        zoom = 0
        hts = str(ht)
        while len(hts) < 3:
            hts = "0" + hts
        plotErrors(e, ua=None, ub=u2, tj=tj, uj=uj, zoom=zoom, png="eh" + hts)
    zoom = 1
    ht = 50
    for mx in [1, 5, 11, nx]:
        ixl = nx / 2 - mx / 2
        ixu = ixl + mx
        nj = 1 + (ni - 1) / ht
        i = rampint(0, ht, nj)
        e = computeErrors(mx, f, g)
        u1 = DynamicWarpingS.findShifts(0.0, 2.0, e)
        uj = DynamicWarpingS.findShiftsI(0.0, 2.0, e, i)
        tj = rampfloat(0.0, ht, nj)
        ti = rampfloat(0.0, 1.0, ni)
        ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC, tj, uj)
        u2 = ci.interpolate(ti)
        mxs = str(mx)
        while len(mxs) < 3:
            mxs = "0" + mxs
        plotErrors(e, zoom=1, png="e" + mxs + "z1")
        plotErrors(e,
                   ua=u1,
                   ub=u2,
                   tj=tj,
                   uj=uj,
                   zoom=1,
                   png="e" + mxs + "uz1")
        if mx == nx:
            plotErrors(e, zoom=2, png="e" + mxs + "z2")
            plotErrors(e,
                       ua=u1,
                       ub=u2,
                       tj=tj,
                       uj=uj,
                       zoom=2,
                       png="e" + mxs + "uz2")
Пример #4
0
def computeErrors(mx, f, g):
    ixl = nx / 2 - mx / 2
    ixu = ixl + mx
    e = zerofloat(nl, ni)
    for ix in range(ixl, ixu):
        ei = DynamicWarpingS.computeErrors(nl, f[ix], g[ix])
        add(ei, e, e)
    return e
Пример #5
0
def computeErrors(mx,f,g):
  ixl = nx/2-mx/2
  ixu = ixl+mx
  e = zerofloat(nl,ni)
  for ix in range(ixl,ixu):
    ei = DynamicWarpingS.computeErrors(nl,f[ix],g[ix])
    add(ei,e,e)
  return e
Пример #6
0
def goErrors():
    zoom = 0
    f, g = getSinoImages()
    f = copy(ni, nx, f)
    g = copy(ni + nl, nx, g)
    e = computeErrors(5, f, g)
    for ht in [1, 25, 50, 100]:
        nj = 1 + (ni - 1) / ht
        i = rampint(0, ht, nj)
        u1 = DynamicWarpingS.findShifts(0.0, 2.0, e)
        uj = DynamicWarpingS.findShiftsI(0.0, 2.0, e, i)
        tj = rampfloat(0.0, ht, nj)
        ti = rampfloat(0.0, 1.0, ni)
        ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC, tj, uj)
        u2 = ci.interpolate(ti)
        zoom = 0
        hts = str(ht)
        while len(hts) < 3:
            hts = "0" + hts
        plotErrors(e, ua=None, ub=u2, tj=tj, uj=uj, zoom=zoom, png="eh" + hts)
    zoom = 1
    ht = 50
    for mx in [1, 5, 11, nx]:
        ixl = nx / 2 - mx / 2
        ixu = ixl + mx
        nj = 1 + (ni - 1) / ht
        i = rampint(0, ht, nj)
        e = computeErrors(mx, f, g)
        u1 = DynamicWarpingS.findShifts(0.0, 2.0, e)
        uj = DynamicWarpingS.findShiftsI(0.0, 2.0, e, i)
        tj = rampfloat(0.0, ht, nj)
        ti = rampfloat(0.0, 1.0, ni)
        ci = CubicInterpolator(CubicInterpolator.Method.MONOTONIC, tj, uj)
        u2 = ci.interpolate(ti)
        mxs = str(mx)
        while len(mxs) < 3:
            mxs = "0" + mxs
        plotErrors(e, zoom=1, png="e" + mxs + "z1")
        plotErrors(e, ua=u1, ub=u2, tj=tj, uj=uj, zoom=1, png="e" + mxs + "uz1")
        if mx == nx:
            plotErrors(e, zoom=2, png="e" + mxs + "z2")
            plotErrors(e, ua=u1, ub=u2, tj=tj, uj=uj, zoom=2, png="e" + mxs + "uz2")