]> git.sesse.net Git - movit/blobdiff - unsharp_mask_effect.h
Add an unsharp mask effect, to complement the more expensive deconvolution sharpening.
[movit] / unsharp_mask_effect.h
diff --git a/unsharp_mask_effect.h b/unsharp_mask_effect.h
new file mode 100644 (file)
index 0000000..45a04f0
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef _UNSHARP_MASK_EFFECT_H
+#define _UNSHARP_MASK_EFFECT_H 1
+
+// Unsharp mask is probably the most popular way of doing sharpening today,
+// although it does not always deliver the best results (it is very prone
+// to haloing). It simply consists of removing a blurred copy of the image from
+// itself (multiplied by some strength factor). In this aspect, it's similar to
+// glow, except by subtracting instead of adding.
+//
+// See DeconvolutionSharpenEffect for a different, possibly better
+// sharpening algorithm.
+
+#include "effect.h"
+
+class BlurEffect;
+class MixEffect;
+
+class UnsharpMaskEffect : public Effect {
+public:
+       UnsharpMaskEffect();
+       virtual std::string effect_type_id() const { return "UnsharpMaskEffect"; }
+
+       virtual bool needs_srgb_primaries() const { return false; }
+
+       virtual void rewrite_graph(EffectChain *graph, Node *self);
+       virtual bool set_float(const std::string &key, float value);
+
+       virtual std::string output_fragment_shader() {
+               assert(false);
+       }
+       virtual void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
+               assert(false);
+       }
+
+private:
+       BlurEffect *blur;
+       MixEffect *mix;
+};
+
+#endif // !defined(_UNSHARP_MASK_EFFECT_H)