Пример #1
0
plt.figure()
plt.imshow(RecFISTA_TV_hub, vmin=0, vmax=0.2, cmap="gray")
plt.title('FISTA-PWLS-HUBER-OS-TV reconstruction')
plt.show()
#%%
from ccpi.filters.regularisers import PatchSelect
print("Pre-calculating weights for non-local patches...")

pars = {'algorithm' : PatchSelect, \
        'input' : RecCGLS,\
        'searchwindow': 7, \
        'patchwindow': 2,\
        'neighbours' : 13 ,\
        'edge_parameter':0.8}
H_i, H_j, Weights = PatchSelect(pars['input'], pars['searchwindow'],
                                pars['patchwindow'], pars['neighbours'],
                                pars['edge_parameter'], 'gpu')

plt.figure()
plt.imshow(Weights[0, :, :], vmin=0, vmax=1, cmap="gray")
plt.colorbar(ticks=[0, 0.5, 1], orientation='vertical')
#%%
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
print("Reconstructing with FISTA PWLS-OS-NLTV method %%%%%%%%%%%%%%")
print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
_regularisation_ = {'method' : 'NLTV',
                    'regul_param' :0.0005,
                    'iterations' : 5,
                    'NLTV_H_i'  : H_i,\
                    'NLTV_H_j'  : H_j,\
                    'NLTV_Weights'  : Weights,\
Пример #2
0
    def process_frames(self, data):
        import numpy as np
        #input_temp = data[0]
        #indices = np.where(np.isnan(input_temp))
        #input_temp[indices] = 0.0
        #self.pars['input'] = input_temp
        input_temp = np.nan_to_num(data[0])
        input_temp[input_temp > 10**15] = 0.0
        self.pars['input'] = input_temp
        #self.pars['input'] = np.nan_to_num(data[0])

        # Running Ccpi-RGLTK modules on GPU
        if (self.parameters['method'] == 'ROF_TV'):
            (im_res,
             infogpu) = ROF_TV(self.pars['input'],
                               self.pars['regularisation_parameter'],
                               self.pars['number_of_iterations'],
                               self.pars['time_marching_parameter'],
                               self.pars['tolerance_constant'], self.device)
        if (self.parameters['method'] == 'FGP_TV'):
            (im_res, infogpu) = FGP_TV(self.pars['input'],
                                       self.pars['regularisation_parameter'],
                                       self.pars['number_of_iterations'],
                                       self.pars['tolerance_constant'],
                                       self.pars['methodTV'],
                                       self.pars['nonneg'], self.device)
        if (self.parameters['method'] == 'SB_TV'):
            (im_res, infogpu) = SB_TV(self.pars['input'],
                                      self.pars['regularisation_parameter'],
                                      self.pars['number_of_iterations'],
                                      self.pars['tolerance_constant'],
                                      self.pars['methodTV'], self.device)
        if (self.parameters['method'] == 'TGV'):
            (im_res,
             infogpu) = TGV(self.pars['input'],
                            self.pars['regularisation_parameter'],
                            self.pars['alpha1'], self.pars['alpha0'],
                            self.pars['number_of_iterations'],
                            self.pars['LipshitzConstant'],
                            self.pars['tolerance_constant'], self.device)
        if (self.parameters['method'] == 'LLT_ROF'):
            (im_res,
             infogpu) = LLT_ROF(self.pars['input'],
                                self.pars['regularisation_parameter'],
                                self.pars['regularisation_parameterLLT'],
                                self.pars['number_of_iterations'],
                                self.pars['time_marching_parameter'],
                                self.pars['tolerance_constant'], self.device)
        if (self.parameters['method'] == 'NDF'):
            (im_res, infogpu) = NDF(
                self.pars['input'], self.pars['regularisation_parameter'],
                self.pars['edge_parameter'], self.pars['number_of_iterations'],
                self.pars['time_marching_parameter'],
                self.pars['penalty_type'], self.pars['tolerance_constant'],
                self.device)
        if (self.parameters['method'] == 'DIFF4th'):
            (im_res,
             infogpu) = Diff4th(self.pars['input'],
                                self.pars['regularisation_parameter'],
                                self.pars['edge_parameter'],
                                self.pars['number_of_iterations'],
                                self.pars['time_marching_parameter'],
                                self.pars['tolerance_constant'], self.device)
        if (self.parameters['method'] == 'NLTV'):
            pars_NLTV = {'algorithm' : PatchSelect, \
                         'input' : self.pars['input'],\
                         'searchwindow': 9, \
                         'patchwindow': 2,\
                         'neighbours' : 17 ,\
                         'edge_parameter':self.pars['edge_parameter']}
            H_i, H_j, Weights = PatchSelect(pars_NLTV['input'],
                                            pars_NLTV['searchwindow'],
                                            pars_NLTV['patchwindow'],
                                            pars_NLTV['neighbours'],
                                            pars_NLTV['edge_parameter'],
                                            self.device)
            parsNLTV_init = {'algorithm' : NLTV, \
                             'input' : pars_NLTV['input'],\
                             'H_i': H_i, \
                             'H_j': H_j,\
                             'H_k' : 0,\
                             'Weights' : Weights,\
                             'regularisation_parameter': self.pars['regularisation_parameter'],\
                             'iterations': self.pars['number_of_iterations']}
            im_res = NLTV(parsNLTV_init['input'], parsNLTV_init['H_i'],
                          parsNLTV_init['H_j'], parsNLTV_init['H_k'],
                          parsNLTV_init['Weights'],
                          parsNLTV_init['regularisation_parameter'],
                          parsNLTV_init['iterations'])
            del H_i, H_j, Weights
        #print "calling process frames", data[0].shape
        return im_res