示例#1
0
from pydeconv import deconv_tv_al, deconv_wiener

from utils import myconvolve, psf


if __name__ == '__main__':
    #2d
    from matplotlib.pyplot import imread

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

    x*= 255
    
    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.)
示例#2
0
from pydeconv import deconv_wiener, deconv_wiener2


from utils import myconvolve, psf


if __name__ == "__main__":

    np.random.seed(0)

    # 2d
    from matplotlib.pyplot import imread

    x = imread("data/usaf.png")
    x = np.pad(x, ((256,) * 2,) * 2, mode="constant")
    h = psf(x.shape, (3.0, 11))

    h2 = psf(x.shape, (11, 3))

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

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

    u1 = deconv_wiener([y, y2], [h, h2], 1.0e-6)

    u2 = deconv_wiener2([y, y2], [h2, h], 1.0e-6)

    # #3d
    # from spimagine import read3dTiff
    #
    # x = read3dTiff("data/usaf3d.tif")[100:228,100:228,100:228]