[FFmpeg-devel] [PATCH] lavfi/WIP: vignette filter.

Michael Niedermayer michaelni at gmx.at
Thu May 30 01:58:45 CEST 2013


On Wed, May 29, 2013 at 02:44:34AM +0200, Clément Bœsch wrote:
> On Mon, May 13, 2013 at 12:31:54AM +0200, Michael Niedermayer wrote:
> > On Fri, May 10, 2013 at 06:49:22PM +0200, Clément Bœsch wrote:
> > > On Thu, Apr 04, 2013 at 05:15:29PM +0200, Clément Bœsch wrote:
> > > [...]
> > > 
> > > New version attached.
> > [...]
> > 
> > > +typedef struct {
> > > +    const AVClass *class;
> > > +    const AVPixFmtDescriptor *desc;
> > > +    int backward;
> > > +    enum EvalMode { EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB } eval_mode;
> > > +#define DEF_EXPR_FIELDS(name) AVExpr *name##_pexpr; char *name##_expr; double name;
> > > +    DEF_EXPR_FIELDS(a);
> > > +    DEF_EXPR_FIELDS(x0);
> > > +    DEF_EXPR_FIELDS(y0);
> > > +    double var_values[VAR_NB];
> > 
> > > +    double *fmap;
> > 
> > isnt double overkill ?
> > 
> 
> Yeah likely. Replaced with float, same for xscale and yscale.
> 
> > 
> > [...]
> > > +static double get_natural_factor(const VignetteContext *s, int x, int y)
> > > +{
> > > +    const int xx = (x - s->x0) * s->xscale;
> > > +    const int yy = (y - s->y0) * s->yscale;
> > > +    const double dnorm = hypot(xx, yy) / s->dmax;
> > > +    if (dnorm > 1) {
> > > +        return 0;
> > > +    } else {
> > > +        const double c = cos(s->a * dnorm);
> > > +        return (c*c)*(c*c); // XXX: do not remove braces, it helps compilers
> > > +    }
> > > +}
> > 
> > this looks a bit unflexible, how well does this work for removing
> > actual vignetting from pictures taken with actual lenses ?
> > 
> 
> I looked more closely at the lens correction, but it actually looks like
> it would belong in a separate filter to me.
> 
> Typically, with lens correction you end up with the following formula:
> 
>   r = a*r^4 + b*r^3 + c*r^2 + d*r
> 
> input r being the distance from the origin of the lens to the current
> pixel (radius) and output r is the new radius. Then you likely have to
> distort the image to achieve the effect; basically "moving pixels" (barrel
> distortion, or its inverse pincushion) which is not what we are doing in
> this filter.
> 
> The cosine 4 formula I use here seems to be the common way of simulating
> the lightning vignetting effect: https://en.wikipedia.org/wiki/Vignetting
> more precisely, the Natural Vignetting (which I now mention in the
> filter's documentation)
> 
> Another lens filter, with different parameters (a, b, c and d) could
> re-use the basis of this filter, but I believe it's a different purpose
> than what I'm trying to achieve here.

fine with me if you prefer.

But we still need a more generic vignette filter to fix all types of
vignetting that occur on a real lense not just one kind

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130530/2506d578/attachment.asc>


More information about the ffmpeg-devel mailing list