X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=deconvolution_sharpen_effect.cpp;h=a90e5cc6f8c1e3463c458e87eb4f451dfdb43a3e;hp=6c319e1b0feceeef04766a232a84e0b759a5bf58;hb=6278a96c8e0ea5df9d831ecd5b893f831ddc8297;hpb=df9cd763a9e433a2f3c9213e7c2342525a5de4cf diff --git a/deconvolution_sharpen_effect.cpp b/deconvolution_sharpen_effect.cpp index 6c319e1..a90e5cc 100644 --- a/deconvolution_sharpen_effect.cpp +++ b/deconvolution_sharpen_effect.cpp @@ -2,15 +2,19 @@ // Since all of our signals are symmetrical, discrete correlation and convolution // is the same operation, and so we won't make a difference in notation. - -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include #include "deconvolution_sharpen_effect.h" +#include "effect_util.h" #include "util.h" -#include "opengl.h" using namespace Eigen; @@ -236,16 +240,6 @@ MatrixXf central_convolve(const MatrixXf &a, const MatrixXf &b) return result; } -void print_matrix(const MatrixXf &m) -{ - for (int y = 0; y < m.rows(); ++y) { - for (int x = 0; x < m.cols(); ++x) { - printf("%7.4f ", m(x, y)); - } - printf("\n"); - } -} - } // namespace void DeconvolutionSharpenEffect::update_deconvolution_kernel() @@ -268,8 +262,7 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel() if (gaussian_radius < 1e-3) { val = (x == 0 && y == 0) ? 1.0f : 0.0f; } else { - float z = hypot(x, y) / gaussian_radius; - val = exp(-z * z); + val = exp(-(x*x + y*y) / (2.0 * gaussian_radius * gaussian_radius)); } gaussian_h(y + 2 * R, x + 2 * R) = val; } @@ -372,8 +365,7 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel() // (G+H) x0 + I x2 = y2 // // This both increases accuracy and provides us with a very nice speed - // boost. We could have gone even further and went for 8-way symmetry - // like the shader does, but this is good enough right now. + // boost. MatrixXf M(MatrixXf::Zero((R + 1) * (R + 1), (R + 1) * (R + 1))); MatrixXf r_uv_flattened(MatrixXf::Zero((R + 1) * (R + 1), 1)); for (int outer_i = 0; outer_i < 2 * R + 1; ++outer_i) { @@ -438,7 +430,6 @@ void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const std update_deconvolution_kernel(); } // Now encode it as uniforms, and pass it on to the shader. - // (Actually the shader only uses about half of the elements.) float samples[4 * (R + 1) * (R + 1)]; for (int y = 0; y <= R; ++y) { for (int x = 0; x <= R; ++x) { @@ -450,5 +441,5 @@ void DeconvolutionSharpenEffect::set_gl_state(GLuint glsl_program_num, const std } } - set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, R * R); + set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, (R + 1) * (R + 1)); }