Beispiel #1
0
        def precond_proximal(self, x, tau, out=None):
            """Modify proximal method to work with preconditioned tau"""
            pars = {
                'algorithm':
                FGP_TV,
                'input':
                np.asarray(x.as_array() / tau.as_array(), dtype=np.float32),
                'regularization_parameter':
                self.lambdaReg,
                'number_of_iterations':
                self.iterationsTV,
                'tolerance_constant':
                self.tolerance,
                'methodTV':
                self.methodTV,
                'nonneg':
                self.nonnegativity,
                'printingOut':
                self.printing
            }

            res, info = regularisers.FGP_TV(pars['input'],
                                            pars['regularization_parameter'],
                                            pars['number_of_iterations'],
                                            pars['tolerance_constant'],
                                            pars['methodTV'], pars['nonneg'],
                                            self.device)
            if out is not None:
                out.fill(res)
            else:
                out = x.copy()
                out.fill(res)
            out *= tau
            return out
Beispiel #2
0
 def proximal_numpy(self, in_arr, tau, out = None):
     res , info = regularisers.FGP_TV(\
           in_arr,\
           self.alpha*tau,\
           self.max_iteration,\
           self.tolerance,\
           self.methodTV,\
           self.nonnegativity,\
           self.device)
     return res, info
    def test_functionality_FGP_TV(self):

        data = dataexample.CAMERA.get(size=(256,256))
        datarr = data.as_array()
        from cil.plugins.ccpi_regularisation.functions import FGP_TV
        from ccpi.filters import regularisers

        tau = 1.
        fcil = FGP_TV()
        outcil = fcil.proximal(data, tau=tau)
        # use CIL defaults
        outrgl, info = regularisers.FGP_TV(datarr, fcil.alpha*tau, fcil.max_iteration, fcil.tolerance, 0, 1, 'cpu' )
        np.testing.assert_almost_equal(outrgl, outcil.as_array())
 def proximal(self, x, tau, out=None):
     in_arr = np.asarray(x.as_array(), dtype=np.float32, order='C')
     res , info = regularisers.FGP_TV(\
           in_arr,\
           self.alpha*tau,\
           self.max_iteration,\
           self.tolerance,\
           self.methodTV,\
           self.nonnegativity,\
           self.device)
     if out is not None:
         out.fill(res)
     else:
         out = x.copy()
         out.fill(res)
     return out
Beispiel #5
0
 def prox(self,x,tau):
     pars = {'algorithm' : FGP_TV, \
            'input' : np.asarray(x.as_array(), dtype=np.float32),\
             'regularization_parameter':self.lambdaReg*tau, \
             'number_of_iterations' :self.iterationsTV ,\
             'tolerance_constant':self.tolerance,\
             'methodTV': self.methodTV ,\
             'nonneg': self.nonnegativity ,\
             'printingOut': self.printing}
     
     out = regularisers.FGP_TV(pars['input'], 
           pars['regularization_parameter'],
           pars['number_of_iterations'],
           pars['tolerance_constant'], 
           pars['methodTV'],
           pars['nonneg'],
           pars['printingOut'], self.device)
     return DataContainer(out)
Beispiel #6
0
    def proximal(self, x, tau, out=None):
        pars = {'algorithm' : FGP_TV, \
               'input' : np.asarray(x.as_array(), dtype=np.float32),\
                'regularization_parameter':self.lambdaReg*tau, \
                'number_of_iterations' :self.iterationsTV ,\
                'tolerance_constant':self.tolerance,\
                'methodTV': self.methodTV ,\
                'nonneg': self.nonnegativity ,\
                'printingOut': self.printing}

        res, info = regularisers.FGP_TV(pars['input'],
                                        pars['regularization_parameter'],
                                        pars['number_of_iterations'],
                                        pars['tolerance_constant'],
                                        pars['methodTV'], pars['nonneg'],
                                        self.device)
        if out is not None:
            out.fill(res)
        else:
            out = x.copy()
            out.fill(res)
        return out