PICCANTE  0.4
The hottest HDR imaging library!
richardson_lucy_deconvolution.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP
19 #define PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP
20 
21 #include "../../gl/image.hpp"
22 
23 #include "../../gl/filtering/filter.hpp"
24 #include "../../gl/filtering/filter_conv_2d.hpp"
25 
26 namespace pic {
27 
29 {
30 public:
35 
38 
40  {
41  flt_conv = NULL;
42  psf_hat = NULL;
43 
44  img_est_conv = NULL;
45  img_err = NULL;
46  img_rel_blur = NULL;
47  }
48 
50  {
51  if(flt_conv != NULL) {
52  delete flt_conv;
53  }
54 
55  if(psf_hat != NULL) {
56  delete psf_hat;
57  }
58 
59  if(img_est_conv != NULL) {
60  delete img_est_conv;
61  }
62 
63  if(img_err != NULL) {
64  delete img_err;
65  }
66 
67  if(img_rel_blur != NULL) {
68  delete img_rel_blur;
69  }
70  }
71 
78  {
80  this->nIterations = nIterations;
81 
82  if(psf != NULL) {
83  this->psf = psf;
84  psf_hat = psf->cloneGL();
85  psf_hat->flipHV();
86  }
87  }
88 
95  ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut)
96  {
97  if((imgIn == NULL) || (psf == NULL)) {
98  return imgOut;
99  }
100 
101  if(flt_conv == NULL) {
102  flt_conv = new FilterGLConv2D(GL_TEXTURE_2D);
103  }
104 
105  auto imgIn_vec = SingleGL(imgIn);
106  /*
107  imgOut = FilterGL::allocateOutputMemory(imgIn_vec, imgOut, false);
108  img_est_conv = FilterGL::allocateOutputMemory(imgIn_vec, img_est_conv, true);
109  img_err = FilterGL::allocateOutputMemory(imgIn_vec, img_err, true);
110  img_rel_blur = FilterGL::allocateOutputMemory(imgIn_vec, img_rel_blur, true);
111  */
112 
113 
114  ImageGLVec vec = DoubleGL(imgOut, psf);
116 
117  *imgOut = 0.5f;
118 
119  for(int i = 0; i < nIterations; i++) {
120 
121  #ifdef PIC_DEBUG
122  printf("%d\n", i);
123  #endif
124 
125  img_rel_blur = imgIn;
126 
129 
130  img_err = flt_conv->Process(vec_err, img_err);
131 
132  *imgOut *= *img_err;
133  }
134 
135  return imgOut;
136  }
137 
138 };
139 
140 }
141 
142 #endif //PIC_GL_ALGORITHMS_RICHARDSON_LUCY_DECONVOLUTION_GL_HPP
RichardsonLucyDeconvolutionGL()
Definition: richardson_lucy_deconvolution.hpp:39
ImageGL * img_rel_blur
Definition: richardson_lucy_deconvolution.hpp:34
ImageGL * psf
Definition: richardson_lucy_deconvolution.hpp:31
int nIterations
Definition: richardson_lucy_deconvolution.hpp:37
PIC_INLINE ImageGLVec SingleGL(ImageGL *img)
SingleGL creates a single for filters input.
Definition: image_vec.hpp:39
ImageGL * cloneGL()
cloneGL
~RichardsonLucyDeconvolutionGL()
Definition: richardson_lucy_deconvolution.hpp:49
The ImageGL class.
Definition: image.hpp:42
The FilterGLConv2D class.
Definition: filter_conv_2d.hpp:30
void flipHV()
flipHV flips horizontally and vertically the current image.
Definition: filter_radial_basis_function.hpp:220
virtual ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
Definition: display.hpp:258
FilterGLConv2D * flt_conv
Definition: richardson_lucy_deconvolution.hpp:36
PIC_INLINE ImageGLVec DoubleGL(ImageGL *img1, ImageGL *img2)
DoubleGL creates a couple for filters input.
Definition: image_vec.hpp:52
ImageGL * img_err
Definition: richardson_lucy_deconvolution.hpp:33
Definition: bilateral_separation.hpp:25
ImageGL * img_est_conv
Definition: richardson_lucy_deconvolution.hpp:32
#define MAX(a, b)
Definition: math.hpp:73
ImageGL * execute(ImageGL *imgIn, ImageGL *imgOut)
execute
Definition: richardson_lucy_deconvolution.hpp:95
void setup(ImageGL *psf, int nIterations)
setup
Definition: richardson_lucy_deconvolution.hpp:77
std::vector< ImageGL * > ImageGLVec
ImageGLVec an std::vector of pic::ImageGL.
Definition: image_vec.hpp:32
ImageGL * psf_hat
Definition: richardson_lucy_deconvolution.hpp:31
Definition: richardson_lucy_deconvolution.hpp:28