Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 12th January 2008, 13:25   #1  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
New Logo Removal Plugin

Hi everybody,

finally I completed my logo removal plugin. This is the abstract from the help file:
Image Inpainting is the art of restoring destroied parts of an image by using information of valid parts of the image in a way, so that the human eye does not recognize the damaged areas (at least not at a first sight). In video processing image inpainting is often applied to videos in order to remove TV station logos. This plugin comes with the intention to provide a suit for the removal of logos, whether opaque or transparent. It provides algorithms for these tasks:
  • Logo detection: An obstacle is analyzed closely after being masked roughly by the user. The exact color map of the logo is determined as well as its alpha mask.
  • Deblending: Given the color image and alpha mask of an overlayed logo, the logo is removed where it is not opaque.
  • Logo inpainting: Opaque parts of the logo are interpolated. A fast method is used which has been published recently by Folkmar Bornemann and Tom März (see here).
Finally, a function for calculating the distance function of a mask is provided, which can be used to expand or inflate masks as well as to provide smooth blending masks.
The logo detection and deblending are (more or less) what you (might) know from Karel Suhajda's DeLogo filter for VirtualDub (but extended to YUV color spaces). The inpainting method is the implementation of a pretty new algorithm which produces much less blurring than the DeLogo filter. As I coded everything in pure C (without CPU optimizations) you shouldn't expect real-time performance.

This mathematics and algorithms (concerning inpainting) behind this plugin are still under heavy development and the effects of the various parameters are not fully understood yet. If you have some experiences with this plugin and some ideas which settings produce good results in which situations, please post them here so the authors can learn from it. Please do not contact any of the authors (WB, FB, TM) directly. Also I should note that this algorithm has originally been developed for inpainting pictures, not movies, so you might observe strong discontinuities in time.

The plugin is attached to this thread as zip-file, including source code, a help file, and a demo script. Everything is licensed under the GNU GPL 2. See files AVSInpaint.htm and GNUGPLv2.txt for details. Have fun!

Regards,
AMSS

Edit: Added version 2008.02.23 as announced here. AMSS
Attached Files
File Type: zip AVSInpaint-2008.01.06.zip (107.6 KB, 2956 views)
File Type: zip AVSInpaint-2008.02.23.zip (87.5 KB, 9120 views)

Last edited by AMSS0815; 23rd February 2008 at 15:41. Reason: added version 2008.02.23
AMSS0815 is offline   Reply With Quote
Old 12th January 2008, 15:46   #2  |  Link
mitsubishi
Registered User
 
Join Date: Sep 2006
Location: UK
Posts: 416
Quote:
Originally Posted by AMSS0815 View Post
(but extended to YUV color spaces)
Sweet. I use the Delogo filter alot, but I only use the alpha deblending. There's maybe a better way of just applying an alpha mask, but that's how I do it.

With Delogo, I just find a blackest possible background the logo and the make my own masks in photoshop.

So I will test this out later.
mitsubishi is offline   Reply With Quote
Old 12th January 2008, 17:09   #3  |  Link
CruNcher
Registered User
 
CruNcher's Avatar
 
Join Date: Apr 2002
Location: Germany
Posts: 4,949
Inpainting goes Avisynth nice work AMSS0815
i think this here is interesting in those regards http://portal.acm.org/citation.cfm?id=1291237

it also seems a nice way for denoise/graining see http://www.mine.tku.edu.tw/advisors/...s/default.aspx Super-Resolution Inpainting
http://www.mine.tku.edu.tw/demo/inpainting/default.aspx
__________________
all my compares are riddles so please try to decipher them yourselves :)

It is about Time

Join the Revolution NOW before it is to Late !

http://forum.doom9.org/showthread.php?t=168004

Last edited by CruNcher; 12th January 2008 at 17:21.
CruNcher is offline   Reply With Quote
Old 13th January 2008, 00:53   #4  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
will look to AVSInPaint!

Surpisingly, I prepare (almost finished, some doc need) two more avisynth impainting plugins
(different algos)
I partially interested in hole filling in motion stabilization and compensation, may be interpolation.

Last edited by Fizick; 13th January 2008 at 09:45.
Fizick is offline   Reply With Quote
Old 13th January 2008, 03:35   #5  |  Link
Malcolm
Registered User
 
Join Date: Sep 2002
Location: Germany
Posts: 352
Hey, this is great!
I was just looking for an inpainting solution for avisynth and bang - the same day you release your plugin!
Just your demo.avs - it's too much for me (it's really late now where i live) Could you just please provide a simple(!) realworld example. maybe a small clip; a logo file and a small avs?
I guess this would really help people to really understand what's needed to use your plugins!

Thanky a lot,
greetings,
Malcolm
Malcolm is offline   Reply With Quote
Old 13th January 2008, 23:54   #6  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
AMSS0815, why you do not use stdcall calling convention instead C? It is now default in avisynth, and extra avisynth_c.dll is not needed

Your plugin is not very slow!

GreyCstoration method in new GreyC plugin is probably slower:
http://forum.doom9.org/showthread.php?t=123081
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 19th January 2008, 14:54   #7  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi there,
Quote:
Originally Posted by CruNcher View Post
i think this here is interesting in those regards http://portal.acm.org/citation.cfm?id=1291237
When I try to download the pdf-file, I'm forwarded to their homepage. I think last summer I read some things about the stuff your other url points to: Seems they're both pretty good and pretty slow. However, I created AVSInpaint because I heard some talks about that algorithm. So I probably won't create more plugins. (Unfortunatelly I'm not in the image processing business anymore.)

Quote:
Originally Posted by Fizick View Post
Surpisingly, I prepare (almost finished, some doc need) two more avisynth impainting plugins
The examples presented in the Microsoft-Paper (for ExInpaint) do look great! I have no opportunity to test it right now. The GREYCstoration seems to apply similar techniques as AVSInpaint (After skim reading their docs, I think they also compute something like Weickert's structuring tensor), but it seems their using an iterative scheme (which might reduce speed significantly)..?

Quote:
Originally Posted by Malcolm View Post
I was just looking for an inpainting solution for avisynth and bang - the same day you release your plugin! ... Could you just please provide a simple(!) realworld example.
Glad to help you. No - I avoid posting image or avi files. But Demo.avs really is a small example, only blown up with stuff that is not inpaint-related:
Please ignore lines 1-130: They only provide the test clip with the logo and a framework to arrange the nice output clip.
Lines 133-139 actually create the test clip, so these lines would be replaced by
Code:
Mask4Analyze = ImageSource("LogoMask.png").ConvertToYV12
AVISource("Movie.avi").ConvertToRGB24
BigMovie=last
Clip=Crop(64,64,64,64)  # Where the logo is and a lot space around
LogoMask.png should be painted by hand, so it is white where the logo is (and some space around) and black elsewhere.
Lines 154-197 will find and remove the logo from Clip and put the result in RepairedClip.
Line 201 layeres the repaired (small) clip on top of the original clip (you will have to change the line by adding x=64 and y=64 or something else, and using BigMovie as base clip). Done.
There is also a small example in the help file (just put in your movie and try)...

Quote:
Originally Posted by Fizick View Post
why you do not use stdcall calling convention instead C
That's something I tried a lot about a year ago, but I failed. At the moment I'm using AviSynth_C.{dll|lib|h} in AviSynth_C-0.15.zip. When replacing AviSynth_C.{lib|h} by those in AviSynth_C-StdCall.zip (and recompiling and removing AviSynth_C.dll and the corresponding line in the avs-file), AviSynth 2.57 (build: Dec 31 2006) replies Unableto load C Plugin: AVSInpaint.dll. When replacing LoadCPlugin with LoadPlugin in the avs-file, I get LoadPlugin: unable to load "AVSInpaint.dll".
I'd appreciate any help in getting rid of this dll-file.

Quote:
Originally Posted by Fizick View Post
Your plugin is not very slow!
very much! Good to hear this.


Andfor all the comments so far!!

Regards,
AMSS
AMSS0815 is offline   Reply With Quote
Old 19th January 2008, 19:21   #8  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
AMSS0815,
avisynth_c from Kevin has known typo bug with ACSC_USE_STDCALL instead of AVSC_USE_STDCALL.
Fixed version is distributed with Avisynth 2.5.7 setup:
avisynth_c.h is with FilterSDK option (and folder)
and avisynth.lib is with Extras option (and folder).
See also Yadif plugin package.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 26th January 2008, 16:54   #9  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Hi Fizick,
Quote:
Originally Posted by Fizick View Post
Fixed version is distributed with Avisynth 2.5.7 setup:
avisynth_c.h is with FilterSDK option (and folder)
and avisynth.lib is with Extras option (and folder).
I tried and failed. To be precise, I (re)placed AviSynth_C.h and AviSynth.lib with the ones comming with AviS 2.5.7, and changed the makefile (so it uses AviSynth.lib). It compiles fine, but linking with the lib-file results in a lot of errors like:
Code:
AVSInpaint.obj(.text+0x6e1):AVSInpaint.c: undefined reference to `_imp__avs_release_video_frame@4'
AVSInpaint.obj(.text+0x1ec7):AVSInpaint.c: undefined reference to `_imp__avs_release_clip@4'
.....
The line #define AVSC_USE_STDCALL 1 suggests that it uses standard calling convention (as far as I looked into the header file, this holds for the imported functions, too).

Quote:
Originally Posted by Fizick View Post
See also Yadif plugin package.
I uncompressed it, and running make resulted in similar error messages (but not so much).
I wonder if my compiler is improperly configured .
By the way: It's gcc 4.2.1 (compiled with some older gcc), and linker is GNU ld 2.15.91 (delivered with MinGW).

AMSS
AMSS0815 is offline   Reply With Quote
Old 26th January 2008, 22:31   #10  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
my first attempt to build avsinpaint failled. - i replace only one avisynth_c.lib to avisynth.lib in make file and missed second entry

Error was similar to reported

But now avsinpaint (and yadif) build fine.

My config:
gcc version 4.0.4
from http://forum.doom9.org/showthread.php?t=108215

GNU ld version 2.17.50 20070129
Seems, it is important! get new binutils 2.17.50

I do not use mingw directly, but with minsys or with Codeblock.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 30th January 2008, 07:33   #11  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
I've wrote a function for AVSInpaint. I hope it will help peoples who have difficulties to use this sympathic plugin. Since it's my first function I ask for leniency.

Code:
#____________________________________________________________________________________
#       _____                   _       _   ______
#      |_   _|                 (_)     | | |  ____|
#        | |  _ __  _ __   __ _ _ _ __ | |_| |__ _   _ _ __   ___
#        | | | '_ \| '_ \ / _` | | '_ \| __|  __| | | | '_ \ / __|
#       _| |_| | | | |_) | (_| | | | | | |_| |  | |_| | | | | (__
#      |_____|_| |_| .__/ \__,_|_|_| |_|\__|_|   \__,_|_| |_|\___|
#                  | |
#                  |_|
#_____________________________________________________________________________________



#  InpaintFunc is a new delogo function using AVSInpaint.dll an AviSynth C plugin developed by AMSS.
#See thread : http://forum.doom9.org/showthread.php?t=133682 to download this plugin and get
#more information about it. Just an advertise : AVSInpaint plugin is rather slow so be patient ;-)


#_______________________________________________________________________________________
#
#    History :
#_______________________________________________________________________________________


# Actual revision : InpaintFunc v1.13

# Author          : Reuf Toc

# Requirement     : AVSInpaint.dll


# Changes         :

#Rev 1.00 :  First release 2008/01/30
#Rev 1.01 :  Add debug for "mode". Removed two useless operations.
#Rev 1.02 :  Added "Speed" parameter.
#Rev 1.03 :  Fixed bug in PAR calculation. Fixed bug with non-RGB32 mask.
#Rev 1.10 :  Fixed bug due to overlay. Added post-processing + a lot of things.
#Rev 1.11 :  Added Show parameter and InpaintAssist function. Process in RGB24 instead of RGB32. 
#Rev 1.12 :  Fixed bug in "loc" calculation
#Rev 1.13 :  Fixed bug for .ebmp creation (did not happen in several cases)
Find last version of InpaintFunc on the wiki : InpaintFunc

Last edited by Reuf Toc; 17th September 2010 at 14:40. Reason: Function updated
Reuf Toc is offline   Reply With Quote
Old 16th February 2008, 19:59   #12  |  Link
geminihc
Registered User
 
Join Date: Jan 2008
Posts: 2
sorry if this questions very stupid, but i'm using FFDshow with avisynth. what exactly do i type in avisynth section in ffdshow to use this..?
geminihc is offline   Reply With Quote
Old 16th February 2008, 23:39   #13  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,356
It'd doubtful that you could do this in realtime even if you put it in ffdshow. You'd also have to change the parameters for every movie's logos.
__________________
There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. ~ Ed Howdershelt
foxyshadis is offline   Reply With Quote
Old 17th February 2008, 06:21   #14  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,685
@ Reuf Toc

I have added your function to the Avisynth wiki.
Here:
http://avisynth.org/mediawiki/InpaintFunc

Feel free to edit and update your function on there when ever you feel like it. (Plus, it makes the function easier to find and maintain.)
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Old 21st February 2008, 08:09   #15  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
Function updated (here and on the Wiki)

The two majors changes are a correction of a bug caused by overlay and the addition of a basic post-processing feature.

Quote:
Changelog :

Fixed bug due to overlay()
Added basic post-processing.
Suppression of Cropval parameter.
Check if the logo analysis has already been computed.
Default value are differents.
Added parameters to tweak InpaintLogo.
Changed debug variables from int to bool.
Changed mask creation method.
Reuf Toc is offline   Reply With Quote
Old 23rd February 2008, 15:40   #16  |  Link
AMSS0815
Registered User
 
Join Date: Aug 2006
Posts: 29
Update to 2008.02.23

Hi everybody,

I updated AVSInpaint to version 2008.02.23. Main change is the removal of AviSynth_C.dll. Thanks to Fizick, this file isn't necessary anymore (Plugin is still loaded with LoadCPlugin). Further (minor) changes are listed in the help file. The file is attached to the original post of this thread.

Nice work, Reuf Toc. I really have to admitt, I didn't spend to much time on making this thing user friendly.

Have fun,
AMSS
AMSS0815 is offline   Reply With Quote
Old 3rd February 2010, 11:37   #17  |  Link
Poutnik
Useless idea generator
 
Poutnik's Avatar
 
Join Date: Apr 2004
Location: Europe, Czech Republic, Brno
Posts: 354
I have a question to InPaincFunc about manual setting of crop area to localize logo ( loc "x1,y1,-x2,-y2" ).

Should I set it to logo quite tightly (with some border) to speed up the things ?
Or, is it a trade off between speed if tight and quality if large enough to have more out-of-logo info ?r
Or it does not matter and "TL" is enough ?
__________________
Vista64 Premium SP2 / C2D E4700 2.6GHz/ 6GB RAM/ Intel GMA 3100 / DTV Leadtek DONGLE GOLD USB2 /
focused to DVB-T MPEG2 PS capture -> ProjectX -> M2V/MP2 -> MeGUI/AVS -> MP4[AVC/AAC]
Poutnik is offline   Reply With Quote
Old 5th February 2010, 13:39   #18  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
I don't know exactly how AVSInpaint works internally but from what I understood, the number of pixels computed to restore the damaged area is defined by "radius" parameter.

So the minimum border around the logo should be at least equal to the radius. If this condition is fulfilled, setting an larger area does not increase quality but only time computation.

So I recommend to use your own loc parameter, especially if your source is HD
Reuf Toc is offline   Reply With Quote
Old 1st July 2010, 18:23   #19  |  Link
pbristow
Registered User
 
pbristow's Avatar
 
Join Date: Jun 2009
Location: UK
Posts: 262
Hi! I'm trying to use AVSinpaint via the InPaintFunc script, as follows:

<code>
LoadCPlugin ("C:\Program Files\AviSynth 2.5\C_plugins\AVSInPaint.dll")

AVISource("GP1.TESTCLIP.avi")
Trim(0,10)

InpaintFunc(mask="G:\GP\Logo_1280x720.bmp", loc="48,48,152,52", speed=20, mode="both", show=false)
</code>


AVSInPaint keeps failing with the error "mask is full". Can anyone explain what that message means? I've searched the docs provided, and the forums, and tried Googling for ' AVSInPaint "mask is full" ' - No luck. (Except for a thread on a Chinese forum, where, if I'm correctly interpreting the machine translation, they don't know what it means either!)

N.B. I'm using the older version of AVSInPaint because I couldn't persuade the newer one to load. (Tried every combination I could think of, using loadplugin/loadCplugin, putting the .dll file in plugins/c_plugins folder, etc. - again, no joy.) If this is a known prob that's fixed in a newer version, could someone point me to it and clarify how it has to be loaded?

Thanks.
pbristow is offline   Reply With Quote
Old 1st July 2010, 19:20   #20  |  Link
Reuf Toc
Registered User
 
Join Date: Feb 2007
Posts: 65
Quote:
Originally Posted by pbristow View Post
Hi! I'm trying to use AVSinpaint via the InPaintFunc script, as follows:

<code>
LoadCPlugin ("C:\Program Files\AviSynth 2.5\C_plugins\AVSInPaint.dll")

AVISource("GP1.TESTCLIP.avi")
Trim(0,10)

InpaintFunc(mask="G:\GP\Logo_1280x720.bmp", loc="48,48,152,52", speed=20, mode="both", show=false)
</code>


AVSInPaint keeps failing with the error "mask is full". Can anyone explain what that message means? I've searched the docs provided, and the forums, and tried Googling for ' AVSInPaint "mask is full" ' - No luck. (Except for a thread on a Chinese forum, where, if I'm correctly interpreting the machine translation, they don't know what it means either!)
"mask is full" means that your mask is "full white" after cropping. Either you cropped too much the clip with the "loc" values you used or there is a problem with your mask (make sure that black parts of your mask are really black).
If you post a screenshot of your source and your mask, I can take a look.

Quote:
Originally Posted by pbristow View Post
N.B. I'm using the older version of AVSInPaint because I couldn't persuade the newer one to load. (Tried every combination I could think of, using loadplugin/loadCplugin, putting the .dll file in plugins/c_plugins folder, etc. - again, no joy.) If this is a known prob that's fixed in a newer version, could someone point me to it and clarify how it has to be loaded?

Thanks.
Have you tried Load_Stdcall_Plugin, the alias for LoadCPlugin ? AVSInpaint is still a C plugin so loadplugin can't work.
Reuf Toc is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.