X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=deconvolution_sharpen_effect.h;h=d7800dff71ce944571d3463a7b34df7b5b8c7f7b;hp=bc0bbd48ee8e07e896624d08b7deb1a41ce0ea69;hb=eff011224abc5dc81f801f3ea44572287a55bcac;hpb=42c35394ef92bb5179fc4879cb55b866fd422d28;ds=sidebyside diff --git a/deconvolution_sharpen_effect.h b/deconvolution_sharpen_effect.h index bc0bbd4..d7800df 100644 --- a/deconvolution_sharpen_effect.h +++ b/deconvolution_sharpen_effect.h @@ -1,5 +1,5 @@ -#ifndef _DECONVOLUTION_SHARPEN_EFFECT_H -#define _DECONVOLUTION_SHARPEN_EFFECT_H 1 +#ifndef _MOVIT_DECONVOLUTION_SHARPEN_EFFECT_H +#define _MOVIT_DECONVOLUTION_SHARPEN_EFFECT_H 1 // DeconvolutionSharpenEffect is an effect that sharpens by way of deconvolution // (i.e., trying to reverse the blur kernel, as opposed to just boosting high @@ -19,21 +19,32 @@ // // Jain, Anil K.: “Fundamentals of Digital Image Processing”, Prentice Hall, 1988. +#include +#include +#include + #include "effect.h" +namespace movit { + class DeconvolutionSharpenEffect : public Effect { public: DeconvolutionSharpenEffect(); - virtual std::string effect_type_id() const { return "DeconvolutionSharpenEffect"; } - std::string output_fragment_shader(); + virtual ~DeconvolutionSharpenEffect(); + std::string effect_type_id() const override { return "DeconvolutionSharpenEffect"; } + std::string output_fragment_shader() override; + + // Samples a lot of times from its input. + bool needs_texture_bounce() const override { return true; } - virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) + void inform_input_size(unsigned input_num, unsigned width, unsigned height) override { this->width = width; this->height = height; } - void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num); + void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override; + AlphaHandling alpha_handling() const override { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; } private: // Input size. @@ -51,6 +62,17 @@ private: // (ie., blur is assumed to be a 2px circle), correlation = 0.95, and noise = 0.01. // Note that once the radius starts going too far past R, you will get nonsensical results. float circle_radius, gaussian_radius, correlation, noise; + + // The deconvolution kernel, and the parameters last time we did an update. + Eigen::MatrixXf g; + int last_R; + float last_circle_radius, last_gaussian_radius, last_correlation, last_noise; + + float *uniform_samples; + + void update_deconvolution_kernel(); }; -#endif // !defined(_DECONVOLUTION_SHARPEN_EFFECT_H) +} // namespace movit + +#endif // !defined(_MOVIT_DECONVOLUTION_SHARPEN_EFFECT_H)