Exemple #1
0
# end function

if __name__ == '__main__':

    plt.close('all')

    if GetNumberOfCUDADevices() > 0:
        mType = MEM_DEVICE
    else:
        print "No CUDA devices found, running on CPU"
        mType = MEM_HOST

    imagedir='./Images/'

    #
    # Run lena images
    #

    I0 = common.LoadPNGImage(imagedir + 'lena_deformed.png', mType)
    I1 = common.LoadPNGImage(imagedir + 'lena_orig.png', mType)

    (Idef, h, energy) = \
           GreedyReg(I0, \
                    I1, \
                    scales = [2,1], \
                    nIters = [1000,1000], \
                    ustep = [0.1, 0.1], \
                    fluidParams = [0.5, 0.5, 0.001], \
                    plotEvery = 500)

Exemple #2
0
def RunTest():

    # number of iterations
    nIters = 2000
    #nIters = 0

    disp = True
    dispEvery = 1000

    if GetNumberOfCUDADevices() > 0:
        mType = MEM_DEVICE
    else:
        print "No CUDA devices found, running on CPU"
        mType = MEM_HOST

    # data fidelity modifier
    DataFidC = 20.0
    # TV modifier
    TVC = 1.0

    TVPow = 1.0

    UseMask = True

    # regularization term to avoid zero denominator
    Beta = 1e-5

    stepI = 0.001

    imagedir = './Images/'

    #
    # Run lena images
    #

    Data = common.LoadPNGImage(imagedir + 'lena_orig.png', mType)

    imSz = Data.size()
    sz = imSz.tolist()[0:2]

    if True:
        I0 = Data.copy()
    else:
        I0 = common.RandImage(nSig=1.0, gSig=5.0, mType=mType)

    Mask = None
    if UseMask:
        bdr = 10
        MaskArr = np.zeros(sz)
        MaskArr[bdr:-bdr, bdr:-bdr] = 1.0
        Mask = common.ImFromNPArr(MaskArr, mType)

    (I, energy) = \
        RunROFTV(Data=Data, \
                     I0 = I0, \
                     DataFidC=DataFidC, \
                     TVC=TVC, \
                     TVPow=TVPow, \
                     stepI=stepI, \
                     Beta=Beta, \
                     nIters=nIters, \
                     dispEvery=dispEvery, \
                     disp=disp, \
                     Mask=Mask)

    print 'final energy: {ttl:n} = {im:n} + {tv:n}'\
        .format(ttl=energy[2][-1], \
                    im=energy[0][-1], \
                    tv=energy[1][-1])
    if GetNumberOfCUDADevices() > 0:
        mType = MEM_DEVICE
    else:
        print "No CUDA devices found, running on CPU"
        mType = MEM_HOST

    # data fidelity modifier
    DataFidC = 1.0
    TVC = 0.05

    imagedir = './Images/'

    #
    # Run lena images
    #

    I0 = common.LoadPNGImage(imagedir + 'lena_orig.png', mType)

    imSz = I0.size()
    sz = imSz.tolist()[0:2]

    (I,energy) = \
        PrimalDualTV(I0, \
                     DataFidC, \
                     TVC = TVC, \
                     nIters = nIters, \
                     stepP = 1.0, \
                     stepI = 1.0/16.0, \
                     disp = disp, \
                     dispEvery = dispEvery)