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

Clément Bœsch ubitux at gmail.com
Thu May 30 17:54:32 CEST 2013


On Thu, May 30, 2013 at 01:58:45AM +0200, Michael Niedermayer wrote:
[...]
> > > > +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.
> 

Thanks, applied.

> 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
> 

Yes, a lens correction filter could be added, but I believe the logic will
be relatively different than this filter.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130530/82369d7b/attachment.asc>


More information about the ffmpeg-devel mailing list