-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MLT movit.sharpen filter using Movit DeconvolutionSharpenEffect.
- Loading branch information
Showing
4 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* filter_deconvolution_sharpen.cpp | ||
* Copyright (C) 2013 Dan Dennedy <dan@dennedy.org> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#include <framework/mlt.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
|
||
#include "glsl_manager.h" | ||
#include "movit/init.h" | ||
#include "movit/deconvolution_sharpen_effect.h" | ||
|
||
static mlt_frame process( mlt_filter filter, mlt_frame frame ) | ||
{ | ||
Effect* effect = GlslManager::add_effect( filter, frame, new DeconvolutionSharpenEffect() ); | ||
if ( effect ) { | ||
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter ); | ||
bool ok = effect->set_int( "matrix_size", mlt_properties_get_int( filter_props, "matrix_size" ) ); | ||
ok |= effect->set_float( "circle_radius", mlt_properties_get_double( filter_props, "circle_radius" ) ); | ||
ok |= effect->set_float( "gaussian_radius", mlt_properties_get_double( filter_props, "gaussian_radius" ) ); | ||
ok |= effect->set_float( "correlation", mlt_properties_get_double( filter_props, "correlation" ) ); | ||
ok |= effect->set_float( "noise", mlt_properties_get_double( filter_props, "noise" ) ); | ||
assert(ok); | ||
} | ||
return frame; | ||
} | ||
|
||
extern "C" { | ||
|
||
mlt_filter filter_deconvolution_sharpen_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg ) | ||
{ | ||
mlt_filter filter = NULL; | ||
GlslManager* glsl = GlslManager::get_instance(); | ||
|
||
if ( glsl && ( filter = mlt_filter_new() ) ) { | ||
mlt_properties properties = MLT_FILTER_PROPERTIES( filter ); | ||
mlt_properties_set_int( properties, "matrix_size", 5 ); | ||
mlt_properties_set_double( properties, "circle_radius", 2.0 ); | ||
mlt_properties_set_double( properties, "gaussian_radius", 0.0 ); | ||
mlt_properties_set_double( properties, "correlation", 0.95 ); | ||
mlt_properties_set_double( properties, "noise", 0.01 ); | ||
filter->process = process; | ||
} | ||
return filter; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
schema_version: 0.1 | ||
type: filter | ||
identifier: movit.sharpen | ||
title: Deconvolution Sharpen (GLSL) | ||
version: 1 | ||
copyright: Dan Dennedy | ||
creator: Steinar H. Gunderson | ||
license: GPLv2 | ||
language: en | ||
tags: | ||
- Video | ||
description: > | ||
Deconvolution Sharpen is a filter that sharpens by way of deconvolution | ||
(i.e., trying to reverse the blur kernel, as opposed to just boosting high | ||
frequencies), more specifically by FIR Wiener filters. It is the same | ||
algorithm as used by the (now largely abandoned) Refocus plug-in for GIMP, | ||
and I suspect the same as in Photoshop's “Smart Sharpen” filter. | ||
The effect gives generally better results than unsharp masking, but can be very | ||
GPU intensive, and requires a fair bit of tweaking to get good results without | ||
ringing and/or excessive noise. It should be mentioned that for the larger | ||
parameters: | ||
- identifier: matrix_size | ||
title: Matrix Size | ||
type: integer | ||
minimum: 0 | ||
maximum: 10 | ||
default: 5 | ||
|
||
- identifier: circle_radius | ||
title: Circle Radius | ||
type: float | ||
minimum: 0 | ||
default: 2 | ||
|
||
- identifier: gaussian_radius | ||
title: Gaussian Radius | ||
type: float | ||
minimum: 0 | ||
default: 0 | ||
|
||
- identifier: correlation | ||
title: Correlation | ||
type: float | ||
minimum: 0 | ||
default: 0.95 | ||
|
||
- identifier: noise | ||
title: Noise Level | ||
type: float | ||
minimum: 0 | ||
default: 0.01 | ||
|