FFmpeg/libavfilter
Jean Delvare 16fd75ceec lavfi/delogo: use weighted interpolation
The original delogo algorithm interpolates both horizontally and
vertically and uses the average to compute the resulting sample. This
works reasonably well when the logo area is almost square. However
when the logo area is significantly larger than high or higher than
large, the result is largely suboptimal.

The issue can be clearly seen by testing the delogo filter with a fake
logo area that is 200 pixels large and 2 pixels high. Vertical
interpolation gives a very good result in that case, horizontal
interpolation gives a very bad result, and the overall result is poor,
because both are given the same weight.

Even when the logo is roughly square, the current algorithm gives poor
results on the borders of the logo area, because it always gives
horizontal and vertical interpolations an equal weight, and this is
suboptimal on borders. For example, in the middle of the left hand
side border of the logo, you want to trust the left known point much
more than the right known point (which the current algorithm already
does) but also much more than the top and bottom known points (which
the current algorithm doesn't do.)

By properly weighting each known point when computing the value of
each interpolated pixel, the visual result is much better, especially
on borders and/or for high or large logo areas.

The algorithm I implemented guarantees that the weight of each of the
4 known points directly depends on its distance to the interpolated
point. It is largely inspired from the original algorithm, the key
difference being that it computes the relative weights globally
instead of separating the vertical and horizontal interpolations and
combining them afterward.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
2013-07-01 09:33:33 +02:00
..
libmpcodecs lavfi/mp: remove mp=spp. 2013-06-14 01:27:22 +02:00
x86 lavfi: add spp filter. 2013-06-14 01:27:22 +02:00
af_aconvert.c
af_afade.c lavfi/afade: add timeline support 2013-05-25 13:20:27 +00:00
af_aformat.c Merge commit 'c5ab6088ad7b0dac461fb6757b038f5260e638e5' 2013-05-18 12:22:25 +02:00
af_amerge.c
af_amix.c
af_anull.c lavfi/anull: remove redundant lines 2013-05-10 15:08:12 +00:00
af_apad.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
af_aphaser.c
af_aresample.c
af_asetnsamples.c
af_asetrate.c
af_ashowinfo.c lavfi/(a)showinfo: use link frame counter instead of local counter. 2013-05-21 22:29:16 +02:00
af_astats.c avfilter/af_astats: rename stat() 2013-06-03 14:59:52 +02:00
af_astreamsync.c
af_asyncts.c Merge commit '16a4a18db089af8c432f1cdec62155000585b72c' 2013-05-10 23:03:50 +02:00
af_atempo.c
af_biquads.c Rename constant HZ in af_biquads.c as HERTZ. 2013-06-30 13:47:45 +02:00
af_channelmap.c lavfi/channelmap: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:31:52 +00:00
af_channelsplit.c
af_earwax.c
af_join.c lavfi/join: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:10:39 +00:00
af_pan.c
af_resample.c
af_silencedetect.c
af_volume.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
af_volume.h
af_volumedetect.c
all_channel_layouts.inc
allfilters.c lavfi: add spp filter. 2013-06-14 01:27:22 +02:00
asink_anullsink.c
asrc_abuffer.h
asrc_aevalsrc.c
asrc_anullsrc.c
asrc_flite.c
asrc_sine.c
audio.c Merge remote-tracking branch 'qatar/master' 2013-06-19 08:27:35 +02:00
audio.h
avcodec.c
avcodec.h
avf_avectorscope.c lavfi: avectorscope filter 2013-05-10 17:11:54 +00:00
avf_concat.c
avf_showspectrum.c
avf_showwaves.c
avfilter.c avfilter/avfilter: Make avfilter_register() thread safe 2013-06-28 12:44:03 +02:00
avfilter.h Merge commit '8b7dffc2d6c6c19f8e0a1fedcd0e95dce7a273ff' 2013-06-05 12:05:41 +02:00
avfiltergraph.c Merge commit '129bb238430ec45a3b5f8f1d384df590ddf7b62f' 2013-05-24 14:07:00 +02:00
avfiltergraph.h
bbox.c
bbox.h
buffer.c
bufferqueue.h
buffersink.c
buffersink.h
buffersrc.c
buffersrc.h
deshake_opencl_kernel.h lavfi: modify names of deshake_kernel.h and unsharp_kernel.h 2013-05-10 12:44:04 +02:00
deshake_opencl.c
deshake_opencl.h
deshake.h
drawutils.c lavfi/drawutils: attempt to fix subsampling. 2013-05-28 19:20:27 +02:00
drawutils.h
dualinput.c lavfi: add dual input helpers. 2013-05-27 20:32:28 +02:00
dualinput.h lavfi: add dual input helpers. 2013-05-27 20:32:28 +02:00
f_ebur128.c
f_interleave.c
f_perms.c
f_select.c lavfi/select: unbreak compatibility with older PICT_TYPE syntax 2013-05-12 10:52:26 +00:00
f_sendcmd.c
f_settb.c
f_zmq.c lavfi: add zmq filters 2013-05-14 20:10:44 +02:00
fifo.c
filtfmts.c Merge commit 'b01f6041f4260fba053c2f96ce1611ea77e833a0' 2013-05-18 11:46:09 +02:00
formats.c Merge commit 'b01f6041f4260fba053c2f96ce1611ea77e833a0' 2013-05-18 11:46:09 +02:00
formats.h Merge commit 'b01f6041f4260fba053c2f96ce1611ea77e833a0' 2013-05-18 11:46:09 +02:00
gradfun.h
graphdump.c
graphparser.c
internal.h Merge commit '129bb238430ec45a3b5f8f1d384df590ddf7b62f' 2013-05-24 14:07:00 +02:00
lavfutils.c
lavfutils.h
libavfilter.v
lswsutils.c
lswsutils.h
Makefile lavfi/mp: remove mp=spp. 2013-06-14 01:27:22 +02:00
opencl_allkernels.c lavfi: modify names of deshake_kernel.h and unsharp_kernel.h 2013-05-10 12:44:04 +02:00
opencl_allkernels.h
pthread.c Rename thread_init() in libavcodec and libavfilter as library_thread_init(). 2013-06-30 13:47:45 +02:00
setpts.c lavfi/setpts: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:14:43 +00:00
split.c
src_movie.c avfilter/src_movie: Fix handling of packet size for video 2013-06-26 13:46:19 +02:00
thread.h Merge commit '129bb238430ec45a3b5f8f1d384df590ddf7b62f' 2013-05-24 14:07:00 +02:00
transform.c
transform.h
trim.c lavfi/trim: mark link closed on EOF. 2013-06-02 23:19:42 +02:00
unsharp_opencl_kernel.h lavfi: modify names of deshake_kernel.h and unsharp_kernel.h 2013-05-10 12:44:04 +02:00
unsharp_opencl.c
unsharp_opencl.h
unsharp.h
version.h lavfi/mp: remove mp=spp. 2013-06-14 01:27:22 +02:00
vf_alphamerge.c
vf_aspect.c Merge commit '3fb29588a27a711132106b924e27b53789a58dcb' 2013-05-17 11:29:22 +02:00
vf_bbox.c lavfi/bbox: export bbox info to frame metadata 2013-05-26 14:00:10 +00:00
vf_blackdetect.c
vf_blackframe.c Merge commit '7f83959598b6565baa0091e5739dd9091ab7a990' 2013-05-16 10:08:17 +02:00
vf_blend.c lavfi/blend: support slice threading 2013-05-24 21:41:28 +00:00
vf_boxblur.c Merge commit '7f83959598b6565baa0091e5739dd9091ab7a990' 2013-05-16 10:08:17 +02:00
vf_colorbalance.c lavfi: cosmetics: fix vertical alignment for pads in some filters 2013-05-14 15:31:56 +00:00
vf_colorchannelmixer.c lavfi: cosmetics: fix vertical alignment for pads in some filters 2013-05-14 15:31:56 +00:00
vf_colormatrix.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_copy.c vf_copy: silence "incompatible pointer type" warning 2013-05-11 15:51:27 +02:00
vf_crop.c Merge commit '3fb29588a27a711132106b924e27b53789a58dcb' 2013-05-17 11:29:22 +02:00
vf_cropdetect.c Merge commit 'ba09675f44612fad9f7169f71b8276beb50a0dcd' 2013-05-16 10:14:00 +02:00
vf_curves.c lavfi: cosmetics: fix vertical alignment for pads in some filters 2013-05-14 15:31:56 +00:00
vf_dctdnoiz.c lavfi/dctdnoiz: move DC normalization out of loops. 2013-05-26 22:41:02 +02:00
vf_decimate.c lavfi: use ceil right shift for chroma width/height. 2013-05-10 17:20:06 +02:00
vf_delogo.c lavfi/delogo: use weighted interpolation 2013-07-01 09:33:33 +02:00
vf_deshake.c avfilter/vf_deshake: check rx 2013-05-18 18:28:59 +02:00
vf_drawbox.c vf_drawbox: give all v_log() a context 2013-06-26 00:54:08 +02:00
vf_drawtext.c add the start_number offset to var_values[VAR_N] directly, instead of adding it in func_frame_num 2013-06-18 17:38:17 -04:00
vf_edgedetect.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_extractplanes.c Merge commit 'b01f6041f4260fba053c2f96ce1611ea77e833a0' 2013-05-18 11:46:09 +02:00
vf_fade.c vf_fade: remove unused function 2013-05-24 20:50:15 +02:00
vf_field.c lavfi/field, il, noise: use av_pix_fmt_count_planes() 2013-05-24 12:53:23 +00:00
vf_fieldmatch.c lavfi: use ceil right shift for chroma width/height. 2013-05-10 17:20:06 +02:00
vf_fieldorder.c Merge commit 'f6b6d6ac42c0ee427fcd3fae4c398b2103b491b8' 2013-05-16 15:21:31 +02:00
vf_format.c lavfi/format: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:17:34 +00:00
vf_fps.c Merge commit '4c205f42c86ccefa093c59434669af34ad14a52b' 2013-05-17 11:05:18 +02:00
vf_framestep.c lavfi/framestep: cosmetics: reindent AVFilter 2013-06-06 17:19:16 +00:00
vf_frei0r.c lavfi/frei0r: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:31:52 +00:00
vf_geq.c lavfi/geq: prefer symbolic constants 2013-05-21 21:15:08 +02:00
vf_gradfun.c Merge commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7' 2013-05-17 10:51:59 +02:00
vf_hflip.c Merge commit '4753f802c00853859b7b4b8fdb79c35e082cb7f8' 2013-05-16 16:45:43 +02:00
vf_histeq.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_histogram.c lavfi/histogram: cache log2 of max_hval 2013-05-19 14:30:42 +00:00
vf_hqdn3d.c lavfi/hqdn3d: make use of AVFILTER_DEFINE_CLASS 2013-05-27 10:58:45 +00:00
vf_hqdn3d.h
vf_hue.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_idet.c lavfi/idet: remove request_frame hack 2013-05-27 09:55:39 +00:00
vf_il.c lavfi/il: add timeline support 2013-06-06 17:44:54 +00:00
vf_interlace.c Merge remote-tracking branch 'qatar/master' 2013-06-18 09:31:05 +02:00
vf_kerndeint.c replace remaining PIX_FMT_* flags with AV_PIX_FMT_FLAG_* 2013-05-15 11:23:14 +02:00
vf_libopencv.c lavfi/ocv: make use of AVFILTER_DEFINE_CLASS 2013-05-27 11:31:52 +00:00
vf_lut3d.c lavfi/lut3d: add sanity checks. 2013-06-07 01:48:41 +02:00
vf_lut.c Merge commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7' 2013-05-17 10:51:59 +02:00
vf_mcdeint.c avfilter/vf_mcdeint: free frame on error 2013-06-03 15:41:29 +02:00
vf_mp.c avfilter/vf_mp: preserve pixel format when possible 2013-06-28 03:32:00 +02:00
vf_mpdecimate.c lavfi: use ceil right shift for chroma width/height. 2013-05-10 17:20:06 +02:00
vf_noise.c lavfi/noise: fix out of array access 2013-05-29 16:54:28 +00:00
vf_null.c
vf_overlay.c lavfi/overlay: remove do_blend forward declaration. 2013-05-27 20:42:46 +02:00
vf_owdenoise.c lavfi: port wavelet denoiser filter from libmpcodecs. 2013-05-16 00:45:45 +02:00
vf_pad.c lavfi/pad: switch to AV_OPT_TYPE_COLOR 2013-05-17 11:32:54 +00:00
vf_pixdesctest.c lavfi/pixdesctest: fix chroma subsampling with odd sizes. 2013-06-01 12:05:55 +02:00
vf_pp.c lavfi/pp: set out frame size. 2013-06-08 23:23:30 +02:00
vf_removelogo.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_rotate.c lavfi/rotate: add angle command 2013-06-13 01:21:47 +02:00
vf_sab.c vf_sab: Fix memleak 2013-06-10 22:00:43 +02:00
vf_scale.c Merge remote-tracking branch 'qatar/master' 2013-05-15 11:10:09 +02:00
vf_separatefields.c
vf_setfield.c
vf_showinfo.c lavfi/(a)showinfo: use link frame counter instead of local counter. 2013-05-21 22:29:16 +02:00
vf_smartblur.c lavfi: replace passthrough_filter_frame with a flag. 2013-05-12 13:07:47 +02:00
vf_spp.c lavfi/spp: fix description. 2013-06-14 06:53:52 +02:00
vf_spp.h lavfi: add spp filter. 2013-06-14 01:27:22 +02:00
vf_stereo3d.c
vf_subtitles.c
vf_super2xsai.c
vf_swapuv.c replace remaining PIX_FMT_* flags with AV_PIX_FMT_FLAG_* 2013-05-15 11:23:14 +02:00
vf_telecine.c replace remaining PIX_FMT_* flags with AV_PIX_FMT_FLAG_* 2013-05-15 11:23:14 +02:00
vf_thumbnail.c
vf_tile.c
vf_tinterlace.c Merge remote-tracking branch 'qatar/master' 2013-06-18 09:31:05 +02:00
vf_transpose.c replace remaining PIX_FMT_* flags with AV_PIX_FMT_FLAG_* 2013-05-15 11:23:14 +02:00
vf_unsharp.c lavfi/unsharp: remove unused float.h include. 2013-05-16 13:38:26 +02:00
vf_vflip.c lavfi/vflip: use FF_CEIL_RSHIFT for chroma w/h rounding. 2013-05-12 12:59:00 +02:00
vf_vidstabdetect.c
vf_vidstabtransform.c
vf_vignette.c lavfi/vignette: remove extra semi-colon. 2013-05-31 10:22:03 +02:00
vf_yadif.c yadif: fix slice sizes 2013-05-24 17:46:57 +02:00
video.c
video.h
vidstabutils.c
vidstabutils.h
vsink_nullsink.c
vsrc_cellauto.c
vsrc_life.c lavfi/life: switch to AV_OPT_TYPE_COLOR 2013-05-17 11:32:54 +00:00
vsrc_mandelbrot.c
vsrc_mptestsrc.c lavfi/mptestsrc: fix chroma subsampling with odd sizes. 2013-06-01 12:05:55 +02:00
vsrc_testsrc.c avfilter/vsrc_testsrc: fix artifacts with odd height 2013-06-24 23:21:17 +02:00
yadif.h yadif: restore speed of the C filtering code 2013-05-14 09:23:55 +02:00