[go: up one dir, main page]

Menu

[r9]: / trunk / cocolib / vtv / vtv.h  Maximize  Restore  History

Download this file

166 lines (120 with data), 5.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef __COCO_VTV_H
#define __COCO_VTV_H
#include <map>
#include <vector>
#include <assert.h>
#include <gsl/gsl_matrix.h>
#include "../cuda/cuda_interface.h"
#include "../defs.h"
#include "../modules.h"
using namespace std;
namespace coco {
/*** CORE PDE METHODS ***/
struct coco_vtv_workspace;
// Helper structure to set all parameters
struct coco_vtv_data
{
// Field size
size_t _W;
size_t _H;
size_t _N;
// Number of channels
size_t _nchannels;
// Smoothness parameter
double _lambda;
// Step sizes (primal/dual)
double _tau;
double _sigma;
// Step sizes (fista)
double _alpha;
// Lipschitz constant
double _L;
// Uniform convexity constant
double _gamma;
// Regularizer
// 0: TV_S
// 1: TV_F
// 2: TV_J
size_t _regularizer;
// Data term regularizer
// 1: L^1 - norm
// 2: L^2 - norm
// Works only together with Arrow-Hurwicz or Chambolle-Pock,
// and with general inverse problem
size_t _data_term_p;
// Number of bytes per image double layer
size_t _nfbytes;
// Workspace data
coco_vtv_workspace* _workspace;
};
// Alloc PDE data with sensible defaults
coco_vtv_data* coco_vtv_alloc( size_t nchannels,
vector<gsl_matrix*> F );
// Free up PDE data
bool coco_vtv_free( coco_vtv_data *data );
// Initialize workspace with current solution
bool coco_vtv_initialize( coco_vtv_data *data,
vector<gsl_matrix*> &U );
// Get current solution
bool coco_vtv_get_solution( coco_vtv_data *data,
vector<gsl_matrix*> &U );
// Get dual variable XI (vector of dimension 2)
bool coco_vtv_get_dual_xi( coco_vtv_data *data,
vector<gsl_matrix*> &XI,
size_t channel=0 );
// Get dual variable ETA (vector of dimension equal to channel number)
bool coco_vtv_get_dual_eta( coco_vtv_data *data,
vector<gsl_matrix*> &ETA );
/*****************************************************************************
TV_x ROF
*****************************************************************************/
// Compute primal energy
double coco_vtv_rof_primal_energy( coco_vtv_data *data );
// *** MTV-ROF base algorithms ***
// Perform one iteration of Bermudez-Morena scheme
bool coco_vtv_rof_iteration_bermudez_morena( coco_vtv_data *data );
// Perform one iteration of Arrow-Hurwicz scheme
bool coco_vtv_rof_iteration_arrow_hurwicz( coco_vtv_data *data );
// Perform one iteration of Algorithm 1, Chambolle-Pock
bool coco_vtv_rof_iteration_chambolle_pock_1( coco_vtv_data *data );
// Perform one iteration of Algorithm 2, Chambolle-Pock
bool coco_vtv_rof_iteration_chambolle_pock_2( coco_vtv_data *data );
// Perform one iteration of FISTA
bool coco_vtv_rof_iteration_fista( coco_vtv_data *data );
/*****************************************************************************
TV_x Deblurring
*****************************************************************************/
// Init kernel
bool coco_vtv_set_separable_kernel( coco_vtv_data *data, gsl_vector *kernel );
bool coco_vtv_set_kernel( coco_vtv_data *data, gsl_matrix *kernel );
// Compute primal energy
double coco_vtv_deblurring_primal_energy( coco_vtv_data *data );
// Perform one primal step (several iterations of gradient descent for the prox operator)
bool coco_vtv_deblurring_primal_step( coco_vtv_data *data );
// Perform one primal step (several iterations of gradient descent for the prox operator)
bool coco_vtv_deblurring_dual_step( coco_vtv_data *data );
// Single primal descent step (using functional gradient only)
bool coco_vtv_deblurring_primal_descent_step( coco_vtv_data *data );
// Perform one iteration of Algorithm 1, Chambolle-Pock
bool coco_vtv_deblurring_iteration_chambolle_pock_1( coco_vtv_data *data );
// Perform one iteration of Algorithm 2, Chambolle-Pock
bool coco_vtv_deblurring_iteration_chambolle_pock_2( coco_vtv_data *data );
// Perform one iteration of Arrow-Hurwicz
bool coco_vtv_deblurring_iteration_arrow_hurwicz( coco_vtv_data *data );
// Perform one single shrinkage step (ISTA)
bool coco_vtv_deblurring_ista_step( coco_vtv_data *data );
// Perform one full iteration of FISTA
bool coco_vtv_deblurring_iteration_fista( coco_vtv_data *data );
/*****************************************************************************
TV_x Inpainting
*****************************************************************************/
// Init inpainting stencil
bool coco_vtv_set_stencil( coco_vtv_data *data, gsl_matrix *stencil );
// Compute primal energy
double coco_vtv_inpainting_primal_energy( coco_vtv_data *data );
// Perform one single shrinkage step (ISTA)
bool coco_vtv_inpainting_ista_step( coco_vtv_data *data );
// Perform one full iteration of FISTA
bool coco_vtv_inpainting_iteration_fista( coco_vtv_data *data );
}
#endif