X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=deconvolution_sharpen_effect.cpp;h=2d32ecd6724d886a03185b1042b643a15a83075b;hp=29071c540c32d93170607012d7e59a9588d604ed;hb=29072985d0a00a53e5b578a1444cee61a0c9e1f2;hpb=ebe6d6ba984b2fb77b365aeacd1f30d4da59964b diff --git a/deconvolution_sharpen_effect.cpp b/deconvolution_sharpen_effect.cpp index 29071c5..2d32ecd 100644 --- a/deconvolution_sharpen_effect.cpp +++ b/deconvolution_sharpen_effect.cpp @@ -5,12 +5,12 @@ #include #include +#include #include #include #include "deconvolution_sharpen_effect.h" #include "util.h" -#include "opengl.h" using namespace Eigen; @@ -250,12 +250,6 @@ void print_matrix(const MatrixXf &m) void DeconvolutionSharpenEffect::update_deconvolution_kernel() { - printf("circular blur radius: %5.3f\n", circle_radius); - printf("gaussian blur radius: %5.3f\n", gaussian_radius); - printf("correlation: %5.3f\n", correlation); - printf("noise factor: %5.3f\n", noise); - printf("\n"); - // Figure out the impulse response for the circular part of the blur. MatrixXf circ_h(2 * R + 1, 2 * R + 1); for (int y = -R; y <= R; ++y) { @@ -274,8 +268,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; } @@ -326,7 +319,6 @@ void DeconvolutionSharpenEffect::update_deconvolution_kernel() assert(r_vv.cols() == 4 * R + 1); // Similarly, r_uv = u ⊙ v = u ⊙ (h ⊙ u) = h ⊙ r_uu. - //MatrixXf r_uv = central_convolve(r_uu, h).block(2 * R, 2 * R, 2 * R + 1, 2 * R + 1); MatrixXf r_uu_center = r_uu.block(2 * R, 2 * R, 4 * R + 1, 4 * R + 1); MatrixXf r_uv = central_convolve(r_uu_center, h); assert(r_uv.rows() == 2 * R + 1); @@ -379,8 +371,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) { @@ -445,7 +436,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) { @@ -457,5 +447,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)); }