DeLogo 1.1 Filter for VirtualDub

1. Table of Contents

2. What is it for?

3. Quick Start

4. Control Reference

5. Mask Reference

6. Error Messages

7. Version History

6. Author and history

7. A few notes

8. Credits

2. What is it for?

The DeLogo filter is designed to remove static elements, i.e. logos or watermarks from video source. While there are many ways how to put a logo to a video, DeLogo filter only covers those that are really static, i.e. not moving and not animated. On the other hand, it can successfully remove alpha-blended logos without destroying the picture beneath.

DeLogo filter features two logo removal techniques. First of them is called DeBlend and it is designed to remove alpha blended logos using given alpha and color mask, which are supposed to be the real alpha and color mask of the logo. While it may be really tricky to create such masks, DeLogo filter features even an analyser which can do all the work for you.

The second technique - repair - comes where the first fails. Opaque logos can not be de-alphed because there is no remnant visible through the logo. These pixels must be painted anew depending on color of pixels surrounding the opaque part.

3. Quick Start

I really believe you don't want to read a long manual to perform such an easy task as logo removal.

1/ Start VirtualDub and open a watermarked video file in it.

I created some sample file using the Making Radius trailer downloaded from DivX website. I've put three logos to it, one over another using Donald Graft's Logo filter. The first was an textured oval with a head blended by about 30%. The second was opaque text "Logo" over the oval. The third was a picture of just the head over them blended by about 40% or so. You can see the masks here:

If you ask, the head picture was taken from the trailer, too.

In the video, the logo looked like this:

2/ Load the DeLogo filter. The configuration dialog should look like this:

Don't fear the disabled controls, they will all get enabled in a few moments :-)

3/ Open the preview window using the Show preview button

note: due to the fact that the dialog is a really big one, I decided not to put the preview window as its child (which makes preview "always on top" of dialog). I used a sort of hack and made the preview window a child of dialog list window. This way you can manipulate the dialog and preview window normally but sometimes the VirtualDub windows may appear on top. Don't fear, just click anywhere in them and the dialog window will pop up back.

4/ In the preview window find some suitable frame where the logo is best visible.

I selected the following one:

4/ Switch to config dialog and press the Save frame button. You can find it in the Mask properties group right to the Analyse mask properties.

note: The preview window will close automatically any time you select any Save or Load button. I decided to do this after the Save/Load dialogs kept appearing behind all the VirtualDub windows.

5/ Select a folder and a file name, then save the picture.

note: all pictures must be in standard 24-bit RGB bitmap format. This applies to all pictures saved or loaded.

note: the saved bitmap is not really the preview window contents. In fact, it is the bitmap as it goes to filter so it doesn't contain any work done by DeLogo filter. It contains result of previous filters though.

6/ Open a bitmap editor (I recommend standard Windows Paint) and open the bitmap in it. 

7/ In the bitmap editor, you can use three colors to mark various parts in the image:

Fine Red (255,0,0) can be used to mark the space occupied by the logo. I recommend not to try to fit the logo pixel by pixel. Mark some pixels bigger space so that you can be sure you marked all.

Fine Blue (0,0,255) can be used to mark "unimportant" part of the image. These pixels will not be used during analysis and they will not be changed in the DeLogo process. They can be used as border pixels by Repair process though.

Fine Green (0,255,0) can be used to mark "not pixels". These pixels will not be used during analysis and they will not be changed by DeBlend nor Repair process. The algorithm will handle them as they are out of the image. I recommend to use it for letterbox part of the image if there is any.

All other colors will be taken as reference area - I recommend to leave them between red and blue part. You could just mark the logo by red but this will force the analyser to analyse whole image and repair the logo according to it while normally the area just surrounding the logo is much better.

Here is what I did:

(sorry for "not fine" colors, what you see is  highly compressed JPG actually; original was fine enough)

8/ Save the image in the same format you loaded it (i.e. 24-bit BMP) and switch back to our config dialog.

9/ Just right from the Save frame button is a Load button which is supposed to load the analysis mask. Push it and select the image you created. Once loaded, the file name and dimensions of the mask should appear. Also the Analyse radio button should be enabled. DeBlend mask should be generated and enabled too.

note: It may take some time to load the mask because there is a lot of pre-computations done.

10/ Press the DeBlend radio button and open the Preview window. You can see something similar to the analysis mask, only the red part edges are somewhat blurred and the image is completely removed. You can adjust the amount of blur using Deblend falloff slider:

11/ If you know that the logo doesn't appear in the whole video, use the Sample frames edit box to enter frame numbers and intervals. You can use just standard way: "-200,300,350-360,400-" means to look for all frames to 200, frame 300, frames 350 to 360 and all frames from 400 to the end. If you enter invalid string here, the Sample video button will become disabled.

note: don't forget that the first frame number in VirtualDub is 0.

note: this field affects analyser only. You can use the On frames: field at the top of the dialog to put similar string for standard filter functionality. This was done due to fact that you may need to be more strict in analysing frames than in processing.

note: do NOT delete frames in the video if you need to specify frames for the filter. All the frame numbers passed to the filter correspond to original video stream including deleted frames.

12/ Hit the Sample video button. This will pop up the standard VirtualDub dialog. Choose sampling mode and run it.

note: filter cannot select which frames it wants to sample so if you specify frames to sample in the Sample frames box, both the VirtualDub and filter selections apply. So if you want to sample all frames specified, you have to select All frames in the sampling dialog.

note: while sampling, you can press the Abort button any time. All analysis done up to that time is kept and used.

note: if you plan to sample a very long video file, the filter may stop analysing quietly in case the internal buffers are about to overflow. Don't be too afraid, this cannot appear sooner than after sampling some 60000 frames.

13/ Once the analysis is done, all the masks should appear. If you have Standard radio button checked, preview window open and are lucky enough, you could see the logo removed in the preview window. In my case, it looked like this:

While it may look good, it is far from perfect. The reason is the head part, which has greater alpha than 50% so all the pixels in it are processed by Repair algorithm instead of DeBlend. Just after moving the Alpha to repair slider a little to the left, the result was way better:

You may notice some remnants of the "Logo" word but the head and oval are almost completely gone.

If you want, you may play a little with the DeBlend and Repair check boxes leaving just the text:

Or just remove the text:

note: once satisfied with the results, you can save the masks using the Save as... buttons. Next time you don't have to run the analysis again, just load the masks.

note: once you close the configuration dialog, all the analysis is lost and the only thing that remains set are the processing masks and parameters. So after you re-open the dialog, you cannot change mask construction parameters until you run another analysis. You can change Repair depth and power though.

note: though I didn't cheat, this is an advertisement example which is supposed to look good (else you would not use it, will you?). The drawback of the DeBlend algorithm is that it boosts the noise because after subtracting the logo it multiplies the remnant (including the noise). The analysis may not give perfect result and tends to produce various artifacts if the frames analysed are not representative enough. The best thing for analysis is a couple of black frames with the logo and a couple of white frames with the logo which can be analysed manually.

4. Controls Reference

Group

Control

Purpose

Enabled

Filter Function

DeBlend

Switches DeBlend processing on/off

When DeBlend, Alpha and Color masks are valid

Repair

Switches Repair processing on/off

When Repair mask is valid

OnFrames checkbox

When checked, only the specified frames are processed
When unchecked or disabled, all frames are processed

When OnFrames edit box contains valid information.

OnFrames edit box

Use to specify which frames contain the logo. All other frames will not be processed by the filter. Empty field means all frames. Beware deleting frames in the source video!

Always

Preview

Standard

Switches standard filter output to be displayed in the Preview window

Always

Analyse

Displays Analyse mask in the Preview window

When Analyse mask is loaded

DeBlend

Displays DeBlend mask in the preview window

When DeBlend mask is valid

Alpha

Displays Alpha mask in the Preview window

When Alpha mask is valid

Color

Displays Color mask in the Preview window

When Color mask is valid

Repair

Displays Repair mask in the Preview window

When Repair mask is valid

Mask properties

Save frame

Saves source of the current frame displayed in the Preview window. You can use this output to create Analysis mask

When the Preview window is open

Save as...

Saves the corresponding mask

When the corresponding mask is valid

Load

Loads the corresponding mask

Always

Repair parameters

Depth

Specifies depth of the border area around pixels to be repaired. The bigger depth the more pixels are used (and the slower the Repair phase is). Yellow pixels represent the border area in the Repair mask.

Always

Power

Specifies the power of repairing. Lower values give more blurred results.

Always

Manual analyser

Reset stats

Clears all the analysis arrays in memory. Start/reset the manual analysis using this button.

Always

Sample frame

Adds the current frame analysis to analysis arrays. After analysing at least two frames you may start experimenting with the results.

When the Preview window is open

Automatic analyser

Sample frames

Use to specify the frames which have to be analysed. You can use the same string as in the OnFrames edit box or be more specific. Beware deleting frames in the source video!

Always

Sample video

Using standard VirtualDub's sampling interface runs through the video and puts specified frames to the analysis arrays

When the Preview window is open and Sample frames box contains valid information

Mask construction parameters

Deblend shift

If you think the result is too bright or too dark, you can try to move this slider a little to reduce that. Lower values tend to not fully remove the logo while higher values tend to make the result brighter.

When the Analysis mask is loaded and some analysis has been done.

Deblend falloff

Use to adjust blurring of the repaired area to its surroundings. The blur is supposed to make the artifacts less visible.

When the Analysis mask is loaded

Alpha to repair

Use to specify how much alpha is needed to mark a pixel as non-deblendable and put it to the Repair mask.

When the Analysis mask is loaded and some analysis has been done.

Repair radius

Use to inflate the Repair mask a little to mask some not ideally DeBlended pixels

When the Analysis mask is loaded and some analysis has been done.

note: "valid" mask means it has been loaded or created and has the same dimensions (in pixels) as processed video.

5. Mask reference

1/Analysis mask

The only significant colors in this mask are Fine red (255,0,0) which marks the "area of interest", Fine blue (0,0,255) which marks the "unimportant" area and Fine green (0,255,0) which marks the "not an image" area. All other colors are transformed to black upon load and these pixels are used as a "reference area" to compare analysis results against pixels in the "area of interest". This mask is copied to the DeBlend mask before blurring.

The difference between blue and green pixels is:

2/ DeBlend mask

In the DeBlend mask, only red channel is significant and marks amount how much the DeBlend process result is blended to the original image. The blue and green part is copied from Analyse mask automatically but it is only for your observation purposes.

When created automatically, Repair mask contents is automatically subtracted from the DeBlend mask to reduce computations.

3/ Alpha mask

Don't ever try to draw the Alpha mask yourself - you will fail. You can try to edit the result though but i don't give you too much chances.

Alpha mask contains alpha value for every color channel in every pixel (so the mask doesn't have to be grayscale). Even more, due to the algorithm used, the alpha value may be bigger than one so alpha=1 is converted to a color value of 200.

4/ Color mask

The same as Alpha mask: just let the analyser create the Color mask for you.

Color mask is supposed to contain color part of the logo. Expect random colors in areas where alpha is near 1.

5/ Repair mask

Repair mask contains Fine red (255,0,0) pixels to be repaired using their surrounding pixels and Fine green (0,255,0) pixels that cannot be used as border pixels. All other colors are turned black upon load. The border pixels are marked yellow for your observation purposes but the border is created automatically using the Repair depth parameter.

When created automatically, Repair mask cannot exceed the "area of interest" marked in Analysis mask even if you raise the Repair radius.

6. Error messages

When something is going wrong, the filter can show an error message. While most of them are pretty self-explanatory, some may confuse you so I decided to explaint them all.

When saving bitmap file:

When loading bitmap file:

7. Version history

1.1 

1.0

8. Author and history

My name is Karel Suhajda and currently I am 35 years old. Once upon a time I was looking for some VirtualDub filter to remove a logo from video and I was surprised there is not any. Then, I found the LogoAway filter by Chris Wojdon which sure is good but didn't do exactly what I expected. So I sat at my computer, learned a little C and created this one.

9. A few notes

  1. The filter is reported to work improperly on older versions of VirtualDub. It has been developped and tested on VirtualDub 1.4.7 so this and newer should work fine.
  2. This filter is memory extensive! It needs up to four images of the same size as the processed video frame loaded to work and allocates some more space for the Repair phase lookup tables (up to equivalent of two another masks). Analyser takes another memory - equivalent of another 6 to 7 bitmaps. Analysis memory is freed upon closing the dialog though.
  3. All the masks used must be exactly the same size as the processed video frame. In other cases the filter will load the image to memory but will not use it and will not turn the corresponding feature on.
  4. You can just load the Repair mask if you remove opaque logo.
  5. You can just load the DeBlend, Alpha and Color masks (omit Repair) if you remove alpha-blended logo.
  6. Don't delete frames in the video if you want to specify frames to process in the filter. If you really need to delete some frames, create intermediate video and process it then.
  7. Avoid putting other filters before this one if you can or expect slower and more painful analysis. Especially don't use temporal based filters such as motion blur or some denoise filters or you MUST run the "All frames" analysis only.
  8. Repair algorithm is the slower the more pixels you have in the Repair mask AND in the border. The processing is done by summing each border pixel to each repaired pixel using weight based on pixel's distance and selected power. So keep the Depth slider low.
  9. Yes, DeLogo filter supports batch processing. As long as there is no way to store the whole bitmaps to the batch script, make sure you have saved all the bitmaps used to local disk which will be accessible on batch run. Also try to make the paths short because they must all fit to single 512 characters long configuration line.
  10. The filter is not greatly optimised - I am not going to learn all the assembly tricks just to make it a little faster. I was trying to speed it up using precalculated data where possible though. Any suggestions are welcome :-)
  11. In case of any questions, you can mail me to kasuha@post.cz
  12. Well... ENJOY!!!

10. Credits

Avery Lee for VirtualDub

Donald Graft for hosting this filter

Chris Wojdon for creating LogoAway – a source of inspiration

Uwe Freese for LogoAway’s UGLARM method