Beispiel #1
0
def test_nlm3_thresh():
    from imgtools import test_images, calcPSNR, read3dTiff
    dev = OCLDevice(useDevice=1)



    # data = test_images.blobs64()

    data = read3dTiff("/Users/mweigert/Data/synthetics/blobs64.tif")

    np.random.seed(0)
    data = 100.*data/np.amax(data)
    y = np.maximum(0,data + np.random.normal(0,20,data.shape))
    y = y.astype(np.float32)
    y = y.astype(np.uint16)

    t = time()
    out = nlm3_thresh(dev,y,2,3,30,60)

    print time()-t
    print calcPSNR(data,out)
    # sigs = np.linspace(3,70,30)

    # bests = []
    # for s0 in np.linspace(2,20,10):
    #     y = data + np.random.normal(0,s0,data.shape)
    #     y = y.astype(np.float32)
    #     sigs = s0*np.linspace(.1,5 ,20)

    #     ind=np.argmax([calcPSNR(data,nlm3_fast(dev,y,2,3,s)) for s in sigs])
    #     print s0,sigs[ind]
    #     bests.append([s0,sigs[ind]])

    return out
Beispiel #2
0
def test_nlm3_thresh():
    from imgtools import test_images, calcPSNR, read3dTiff
    dev = OCLDevice(useDevice=1)



    # data = test_images.blobs64()

    data = read3dTiff("/Users/mweigert/Data/synthetics/blobs64.tif")

    np.random.seed(0)
    data = 100.*data/np.amax(data)
    y = np.maximum(0,data + np.random.normal(0,20,data.shape))
    y = y.astype(np.float32)
    y = y.astype(np.uint16)

    t = time()
    out = nlm3_thresh(dev,y,2,3,30,60)

    print time()-t
    print calcPSNR(data,out)
    # sigs = np.linspace(3,70,30)

    # bests = []
    # for s0 in np.linspace(2,20,10):
    #     y = data + np.random.normal(0,s0,data.shape)
    #     y = y.astype(np.float32)
    #     sigs = s0*np.linspace(.1,5 ,20)

    #     ind=np.argmax([calcPSNR(data,nlm3_fast(dev,y,2,3,s)) for s in sigs])
    #     print s0,sigs[ind]
    #     bests.append([s0,sigs[ind]])

    return out
Beispiel #3
0
def test_bm4d():
    from imgtools import test_images, calcPSNR, read3dTiff
    dev = OCLDevice()

    data = test_images.blobs64()

    data = read3dTiff("/Users/mweigert/Data/synthetics/filaments64.tif")

    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    out = bm4d(y,20)
    print calcPSNR(data,out)
    sigs = np.linspace(3,70,30)

    return data,out
Beispiel #4
0
def test_bm4d():
    from imgtools import test_images, calcPSNR, read3dTiff
    dev = OCLDevice()

    data = test_images.blobs64()

    data = read3dTiff("/Users/mweigert/Data/synthetics/filaments64.tif")

    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    out = bm4d(y,20)
    print calcPSNR(data,out)
    sigs = np.linspace(3,70,30)

    return data,out
Beispiel #5
0
def test_dct():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100. * data / np.amax(data)
    y = data + np.random.normal(0, 20, data.shape)
    y = y.astype(np.float32)

    out = dct_8x8(y, 60)
    outs = [calcPSNR(data, dct_8x8(y, s)) for s in np.linspace(10, 60, 20)]
    return out
Beispiel #6
0
def test_bilateral():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    outs  = [calcPSNR(data,bilateral(y,2,sigs)) for sigs in np.linspace(1.,200,20)]

    return outs
Beispiel #7
0
def test_dct():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    out = dct_8x8(y,60)
    outs  = [calcPSNR(data,dct_8x8(y,s)) for s in np.linspace(10,60,20)]
    return out
Beispiel #8
0
def test_nlm_fast():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100. * data / np.amax(data)
    y = data + np.random.normal(0, 20, data.shape)
    y = y.astype(np.float32)

    out = nlm_fast(y, 2, 3, 5.)
    sigs = np.linspace(3, 70, 30)
    outs = [calcPSNR(data, nlm_fast(y, 2, 3, s)) for s in sigs]

    bests = []
    for s0 in np.linspace(2, 20, 10):
        y = data + np.random.normal(0, s0, data.shape)
        y = y.astype(np.float32)
        ind = np.argmax([calcPSNR(data, nlm_fast(y, 2, 3, s)) for s in sigs])
        print ind
        bests.append([s0, sigs[ind]])

    print "nlm fast: sig_max = %s" % sigs[np.argmax(outs)]
    return bests
Beispiel #9
0
def test_bilateral():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100. * data / np.amax(data)
    y = data + np.random.normal(0, 20, data.shape)
    y = y.astype(np.float32)

    outs = [
        calcPSNR(data, bilateral(y, 2, sigs))
        for sigs in np.linspace(1., 200, 20)
    ]

    return outs
Beispiel #10
0
def test_nlm_fast():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    out = nlm_fast(y,2,3,5.)
    sigs = np.linspace(3,70,30)
    outs  = [calcPSNR(data,nlm_fast(y,2,3,s)) for s in sigs]


    bests = []
    for s0 in np.linspace(2,20,10):
        y = data + np.random.normal(0,s0,data.shape)
        y = y.astype(np.float32)
        ind=np.argmax([calcPSNR(data,nlm_fast(y,2,3,s)) for s in sigs])
        print ind
        bests.append([s0,sigs[ind]])

    print "nlm fast: sig_max = %s" %sigs[np.argmax(outs)]
    return bests
Beispiel #11
0
def test_nlm():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100. * data / np.amax(data)
    y = data + np.random.normal(0, 20, data.shape)
    y = y.astype(np.float32)

    out = nlm(y, 2, 3, 25.)
    sigs = np.linspace(2, 70, 10)

    outs = [calcPSNR(data, nlm(y, 2, 3, s)) for s in sigs]
    print "nlm: sig_max = %s" % sigs[np.argmax(outs)]

    return outs
Beispiel #12
0
def test_nlm():
    from imgtools import test_images, calcPSNR

    data = test_images.lena()
    data = 100.*data/np.amax(data)
    y = data + np.random.normal(0,20,data.shape)
    y = y.astype(np.float32)

    out = nlm(y,2,3,25.)
    sigs = np.linspace(2,70,10)

    outs  = [calcPSNR(data,nlm(y,2,3,s)) for s in sigs]
    print "nlm: sig_max = %s" %sigs[np.argmax(outs)]

    return outs