예제 #1
0
파일: demo_image.py 프로젝트: syarra/nlpy
class Image1DMinresAug(Image1D):
    def __init__(self, n=80, sig=0.05, err=2, **kwargs):
        Image1D.__init__(self, n, sig, err, **kwargs)
        self.reg = kwargs.get("reg", 1.0e-3)

    def setsolver(self):
        n = self.n
        op = SimpleLinearOperator(n, n, self.matvec, symmetric=True)
        self.solver = Minres(op, check=True, show=True)

    def matvec(self, x):
        "y <- Ax"
        (m, n) = self.K.shape
        y = np.empty(n + m)
        y[:m] = x[:m] + np.asarray(x[m:] * self.K)[0]
        y[m:] = np.asarray(x[:m] * self.K.T)[0] - self.reg * x[m:]
        return y

    def deblur(self, **kwargs):
        "Deblur image with specified solver"
        b = np.zeros(2 * self.n)
        b[: self.n] = self.data
        self.solver.solve(b, **kwargs)
        return self.solver.x
예제 #2
0
파일: demo_image.py 프로젝트: syarra/nlpy
 def setsolver(self):
     n = self.n
     op = SimpleLinearOperator(n, n, self.matvec, symmetric=True)
     self.solver = Minres(op, check=True, show=True)