Esempio n. 1
0
    return ws[np.argmin([mse(x, deconv_wiener(y, h, w)) for w in ws])]


if __name__ == "__main__":
    np.random.seed(0)
    # 2d
    from matplotlib.pyplot import imread

    s = 0.05
    x = imread("data/usaf.png")

    x *= 0
    x[200:400, 200:400] = 1.0

    mu = 10000.0
    rho = 10.0

    scale = 100

    x *= 1.0 * scale

    h = psf(x.shape, (6.0, 6.0))

    y = myconvolve(x, h) + s * np.amax(x) * np.random.uniform(0, 1, x.shape)

    # u = deconv_tv_al([y,y2],[h,h2])

    u = deconv_tv_al(y, h, mu, rho)

    u2 = deconv_wiener(y, h, rho / mu)
Esempio n. 2
0
    
    h = psf(x.shape,(3.,11))


    h = psf(x.shape,(5.,5.))

    h2 = psf(x.shape,(11,3))
    
    y = myconvolve(x,h)+s*np.amax(x)*np.random.uniform(0,1,x.shape)

    y2 = myconvolve(x,h2)+s*np.amax(x)*np.random.uniform(0,1,x.shape)

    # u = deconv_tv_al([y,y2],[h,h2])

    
    u = deconv_tv_al(y,h,10.,1.)

    u2 = deconv_wiener(y,h,0.1)
    
    #3d
    from spimagine import read3dTiff

    x = read3dTiff("data/usaf3d.tif")[100:228,100:228,100:228]
    h = psf(x.shape,(3.,3.,11))

    h2 = psf(x.shape,(11,3,3))
    h3 = psf(x.shape,(3,11,3))
    
    y = myconvolve(x,h)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)
    y2 = myconvolve(x,h2)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)
    y3 = myconvolve(x,h3)+.1*np.amax(x)*np.random.uniform(0,1,x.shape)