DeLogo Filter for VirtualDub

version 1.3.2

1. Table of Contents

2. What is it for?

3. Quick Start

3.1 Still Images

3.2 Opaque Logos in Video

3.3 Alpha-blended Logos

3.4 What Next

4. Controls Reference

5. Mask Reference

5.1 Analysis Mask

5.2 DeBlend Mask

5.3 Alpha Mask

5.4 Color Mask

5.5 Repair Mask

6. Error Messages

7. Version History

8. Author and History

9. Frequently Asked Questions

10. 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 deblended 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

The filter configuration dialog looks like this:

All the values and settings showed on this picture are the default values.

In the following sections you will find some tasks - from the most trivial to somewhat complex one - that I actually did using the filter to achieve the result. Remember that not all controls are actually used and explained in this part, for detailed description refer to reference sections.

3.1 Still Images

Though VirtualDub is primarily intended to edit video, since version 1.4.8 it is possible to load a series of .bmp images as a video sequence. The sequence may even consist of just one frame which makes it a complicated image processing tool. While for many cases there are much better tools to do the same, the DeLogo filter is actually the only tool I know capable to remove unwanted elements from an image without a lot of editing. Only the repair technique can be used for still images (DeBlend process needs to analyse at least two frames to get some results) so this is actually the most simple task you can use the filter for.

  1. Take an image with some unwanted elements, such as a photo with a timestamp:

  2. Convert the image to the .bmp format. There are many ways how to do it, but in case of lack of other suitable tools, it is still possible to press the PrintScreen key and paste the image to the Windows Paint program.
  3. Open the image in some image editing tool (such as Windows Paint) and mark all unwanted elements by a fine red (255, 0, 0) color:

    Don't hesitate to mark some extra pixels around the object, it is always better than to leave some artifacts to extend to the repaired area.
  4. Save the image to a numbered file, e.g. "Photo1.bmp", use a 24-bit color format. The number in the name is a tribute to VirtualDub, which expects a number in the filename to load it as a video frame. The 24-bit color format is required by the filter.
  5. Start the VirtualDub and open the bitmap as a 1-frame video in it.
  6. Open the Filters dialog and add the DeLogo filter to it. The filter configuration box will open.
  7. Press the Load... button next to the Repair: text in the Mask properties group and load the image here.
  8. Press the Show preview button and look at the result:

  9. For further improvements you may try to play a little with the controls in the Repair parameters group. Don't expect miracles - the marked area is only replaced by a weighted average of surrounding pixels. The weight is specified by the Power value while Depth affects the number of surrounding pixels. If you press the Repair radio button in the Preview group, you can see how many surrounding pixels (yellow) are used as the border:

    Note also that every continuous repaired area is processed on its own and has its own border. You can notice it when you pull the Power slider to the left end (value 0.0) which means a constant average of the border pixels. Each area will have its own constant color. This feature greatly increases processing speed for such complicated masks consisting of many parts.
  10. Press the Close button to close the filter configuration dialog and OK button to close the filters dialog. Then save the result using File/Save image sequence... menu choice.

3.2 Opaque Logos in Video

Opaque logos are for sure the most common case. As you can expect, the DeBlend algorithm can't be applied to opaque logos so the process is actually very similar to the still image provessing.

  1. Start the VirtualDub, open the video to be processed in it:

  2. Open the Filters dialog and add the DeLogo filter.
  3. Press the Show preview button and seek in the video until you find a frame where the logo is best visible:

  4. Press the Save frame button (next to the Analyse: text in the Mask properties group) and choose a folder and a name for the bitmap image containing your selected frame. Save it by pressing the Save button.
  5. Open the image in your preferred image editor (e.g. Windows Paint) and mark the logo by a fine red (255, 0, 0) color:

    Note that the mask is actually much wider than the logo. The logo in this example is not completely opaque, it contains an alpha-blended "shadow" and some color artifacts which destroy the result if they are not masked too.
  6. Press the Load button next to the Repair: text in the Mask properties group and load the mask you just created as a Repair mask.
  7. Press the Show preview button and check the result:

  8. You can enhance the result using the controls in the Repair parameters group. If the video is interlaced, check the Interlaced checkbox. Also if the video doesn't have pixel aspect ratio 1:1, you can use the Pixel aspect slider to compensate it. For detailed description, see the Controls reference section.
  9. Press the Close button to close the filter configuration dialog and OK button to close the filters dialog. Continue processing the video as usual.

3.3 Alpha-blended Logos

The alpha-blended logo removal feature is the main strength of the DeLogo filter. It is a simple task to alpha-blend a logo to a video but it turns out to be really tricky to remove it if you don't have the original logo and its alpha mask. Using the DeLogo filter it is necessary to find the original logo and its alpha mask first using the analysis procedure.

  1. Start VirtualDub and open the video file with a logo:

    Let's omit the TV logo in the upper left corner and concentrate just on the huge blue bar at the bottom of the image. Most of it is transparent but there are some opaque parts too.
  2. Open the Filters dialog and load the DeLogo filter.
  3. Press the Show preview button. In the Preview window and find a frame where the logo is best visible.
  4. Press the Save frame button (next to the Analyse: text in the Mask properties group) and choose a folder and a name for the bitmap image containing your selected frame. Save it by pressing the Save button.
  5. Open the image in your preferred image editor (e.g. Windows Paint) and mark the logo and some area around it by a fine red (255, 0, 0) color. Leave some area around the logo as is and mark the remaining area by full blue (0, 0, 255) color:

    The red area is the area where the analyser will look for the logo. The logo itself should be a few pixels smaller than the marked area. The blue area will be omitted by the analyser, i.e. the analysis results from the blue area will not be used in any way. The remaining area (original color) will be used as a reference area - the analysis results for pixels in this area will be compared with the analysis results for pixels in the red area to find the alpha and color values. It is therefore a good idea to leave the reference area near the analysed area but not to make it too big.
  6. In the DeLogo configuration dialog, press the Load button next to the Analyse: text in the Mask properties group and load the mask as an analysis mask.
  7. Both Analysis and DeBlend masks should be enabled now. The Analysis mask contains your mask with reference area changed to black instead of original picture. The DeBlend mask is very similar but the red area edge is somewhat smeared to the reference area:

    The smearing width can be adjusted by the DeBlend falloff slider. It causes the DeBlend process to extend a little to the reference area to prevent a visible edge between repaired and non-repaired area.
  8. Now it's time to analyse the video. Open the Preview window if it is not already open and press the Sample video button. In the next dialog, choose a sampling mode - I recommend to sample all frames, but for longer videos it might not be really practical.
    Note that if the logo doesn't appear on the whole video, you must specify frames where the logo should be analysed or you don't get usable results. In such case, see Controls Reference section for further details.
  9. When the analysis is done, all masks should be created in the filter dialog. For the DeBlend process, the most important are the Alpha and Color masks:

    In the color mask, you can see what the filter thinks about the original logo color. At logo area, it should match the logo. In other areas you can expect random colors.

    The Alpha mask should contain the original logo alpha channel. The darker the color the less transparent the logo is. You can see a problem in my example - the opaque parts of the logo have bright edges. It is caused by the fact that the logo was not really still - it moved slightly to the left and right probably due to instability of my TV capture card. This confused the analysis algorithm and it marked these parts as transparent.
  10. If the Color and Alpha masks are OK, it is possible to use the Alpha mask to produce the Repair mask using the Alpha to repair and Repair radius sliders. Due to the problem in the Alpha mask, I decided to make the Repair mask manually from the Alpha mask - I saved the Alpha mask using the appropriate Save button, edited the bitmap in Windows Paint and loaded the repair mask using appropriate Load button. The final repair mask looked like this:

    Note that this is the Repair mask exported from the filter - I didn't put the yellow border in manually, it is done by the filter after loading the mask.
  11. The result of combined Repair and DeBlend processing can be seen in the Preview window:

    You can find higher level of noise at the deblended area and blurred replacements at the repaired areas but the result is still much better than if there is the logo.

3.4 What Next

This tutorial only shows a simple case of the filter usage. There are many things unused or not explained. Read thoroughly the Mask reference and Controls reference sections to get full information about the filter.

I recommend you to concentrate on other mask features, namely a green color usage in Analyse and Repair masks. It is particularly useful for a letterboxed video processing or for still images processing when you don't want certain part to expand to the repaired area.

The analysis process can be done manually on a selected set of frames too. In some circumstances, its result may be better than a complete video analysis. Particularly if you find one completely white and one completely black frame with the logo, analysing just these two frames might be enough to produce high quality Color and Alpha masks.

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 will be processed. "frame1" means processing frame1 only "frame1-frame2" means processing frames from frame1 to frame2 including both ends "-frame2" means processing all frames from the beginning to frame2 including frame2. "frame1-" means processing all frames from frame1 to the end including frame1 It is possible to specify multiple frames or regions separated by commas. Example: "-100,150-320,330,331,333,400-" The frame numbers are the frame numbers in the source video stream and deleting parts of video may lead to confusion here. | 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 | (name column) | Shows the mask filename. "- none -" text is displayed here if no mask is loaded. "- generated -" means that the mask was created by the filter and was not saved yet. |
 | (size column) | Shows the mask size in pixels (width x height). The mask size must be equal to the video image size in order to filter use the mask. |
 | 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
 | Interlaced | Specifies that even and odd lines of the video image should be processed separately. Improves the result on interlaced video. | Always
 | Pixel aspect | Specifies the pixel aspect ratio. When calculating the pixel distances, appropriate axis distance is multiplied by the aspect ratio coefficient. Useful when the pixel aspect ratio is not 1:1, e.g. when capturing in 352x576 format. It also affects the border size and shape. | 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 statistics to analysis arrays. After analysing at least two frames you may start experimenting with the results. | When the Preview window is open
 | Subtract frame | Subtracts the current frame statistics from analysis arrays. It is possible to 'undo' a manually analysed frame using this key or to create some fancy effects by subtracting frames not yet analysed (not recommended). | 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 (i.e. select less frames). The frame numbers are the frame numbers in the source video stream and deleting parts of video may lead to confusion here. | Always
 | Sample video | Using the standard VirtualDub's sampling interface runs through the video and puts specified frames statistics 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. I didn't ever get better result using this slider. | 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 that it has been loaded or created and has the same dimensions (in pixels) as the processed video.

5. Mask Reference

All masks can be saved and loaded as a 24-bit color standard Windows bitmap (.bmp) images. No other format of the bmp file is supported and an attempt to load it will cause an error.

5.1 Analysis Mask

While the statistical analysis runs on every pixel in the whole image area, the Analysis mask tells the analyser how to use the statistical results.

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 "area of interest" (red) means the area where the analyser should try to find the logo. This area should be somewhat larger than the logo in order to cover all its parts that might not be clearly visible.

The "unimportant" (blue) area contains pixels which are statistically analysed and used to create the Alpha and Color masks, but they are not used in calculating the coefficients making the Alpha and Color masks. This area is not marked to be repaired by the automatically created DeBlend mask too.

The "not an image" (green) area is handled the same way as the "unimportant" (blue) area but its shape is also transferred to the Repair mask preventing the Repair algorithm to use marked pixels as border pixels.

The difference between the blue and green area is:

  • When creating the DeBlend mask, the blur fades to blue pixels even though the falloff value is bigger. Green pixels don't stop the blur which may result in a visible edge in the result:

  • Green pixels are copied to the Repair mask where they play their own role.

5.2 DeBlend Mask

In the DeBlend mask, only the red channel is significant and marks the amount how much the DeBlend process result is blended to the original image. The fine blue and fine green areas are left here for your observation purposes. The Repair mask is subtracted from the DeBlend mask to reduce computing, too; the red color covered by the repair mask is changed to cyan.

5.3 Alpha Mask

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

It is not a good idea to try to draw the Alpha mask manually. Let the analyser do its work - you can try to use the manual analysis on a selected set of frames to achieve better results.

5.4 Color Mask

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

Color mask is supposed to contain the color part of the logo. Expect random colors in areas where the alpha is near 1 (i.e. almost transparent logo).

5.5 Repair Mask

The 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 and Pixel aspect parameters:

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

Every continuous marked area is repaired independently on other areas and it has its own border which may occasionally re-use border pixels of other areas. When the Interlaced option is on, each field is processed independently too and corresponding border pixels are taken from the same field only (thus, a continuous red marked area actually makes two continuous areas in interlaced mode).

The border area shape is slightly affected by the Interlaced option (may expand around 1 pixel up and down) and heavily affected by the Depth parameter (border width in pixels) and the Pixel aspect parameter (the border takes more pixels on the "thinner" axis).

If you create a repair mask region which has no border pixels (e.g. red area completely surrounded by green pixels), that area is not repaired.

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 explain them all.

When saving a bitmap file:

  • Not enough memory to save bitmap - only a small chunk of memory has to be allocated to save a bitmap file. Stop some application and try again.
  • Can't create file - the folder or disk is locked or the filename is wrong.
  • Error writing bitmap file - probably there is not enough space on your disk or you removed media from drive.

When loading a bitmap file:

  • Bitmap file not found - you managed somehow to enter a file name that was not found on your computer.
  • Error reading bitmap file - the bitmap file you selected is locked or open by another program.
  • Selected file is corrupted or it is not a bitmap file - the bitmap file is not readable as bitmap file.
  • Only uncompressed 24-bit RGB buttom-up bitmaps are supported - you managed to save the bitmap file in format that the filter is unable to read. Try to open and re-save it in Windows Paint.
  • Not enough memory to load bitmap file - sad one. Your bitmap is too big or your RAM is too small.
  • Mask dimensions (X x Y) don't correspond to video (X x Y) - the mask must have exactly the same dimensions as the video processed. Likely you cropped or resized the mask after you saved it from the video.
  • Mask must contain at least one repair pixel and at least one reference pixel - before you load the analysis mask, make sure there is a red area (repair pixels) and some non-red/green/blue area (reference pixels). Also make sure that the area you marked red is marked by the right shade of red, i.e. fine red (255, 0, 0).

When saving a batch:

All the error messages only mean that not all the masks used are saved and the DeLogo function after loading from the batch will be different from the current function.

  • Masks for the Repair and DeBlend functions are not saved; the DeLogo filter will have no function.
  • The Repair mask is not saved; the DeLogo filter Repair function will be suppressed.
  • The Repair mask is not saved; the DeLogo filter will have no function.
  • The DeBlend function masks are not saved; the DeLogo filter DeBlend function will be suppressed.
  • The DeBlend function masks are not saved; the DeLogo filter will have no function.

7. Version History

1.3.2

  • Fixed a bug in frame range specification parser (introduced in version 1.3.1)

1.3.1

  • Fixed a bug that caused the filter to crash on loading DeBlend mask
  • Fixed a bug that caused the filter to crash on changing Alpha to repair value

1.3

  • Fixed a bug in batch mode causing errors when some masks were not saved
  • Added a warning message to batch save procedure reporting unsaved masks
  • Added possibility to subtract ('undo') a frame during manual analysis
  • Fixed some issues in the manual
  • Added a few Q/As to FAQ
  • Added Jean-Francois Pirus to the Credits section

1.2.1

  • A stupid bug strikes again, this time it prevented the batch-mode function. Thanks come to Jean-Francois Pirus for finding this one. Fixed for good.

1.2

  • Fixed a bug in bitmap saver/loader causing "rainbows" on odd widths.
  • Made slider value fields show real value instead of integer representation
  • Added "interlaced" option to repair parameters
  • Added "pixel aspect" option to repair parameters
  • Changed the method how the Repair mask is subtracted from the DeBlend mask
  • Completely rewrote the repair algorithm, enhanced its speed particularly when multiple independent regions are repaired
  • Rewrote the Quick start section and revised the rest of the manual

1.1

  • Fixed stupid bug causing improper function when cropping was used
  • Enhanced bitmap save/load procedures to be more effective
  • Repaired bugs in the manual
  • Added Error messages and Version history sections to the manual

1.0

  • initial release, thoroughly tested and hoped to be fully functional

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. Frequently Asked Questions

Q: What VirtualDub version do I need to use this filter?

A: I always recommend to use the newest version of VirtualDub. The first version that runs the filter with no known problems is 1.4.7.

Q: I have specified frames to analyse in the Sample frames edit box but the filter still analyses the whole video.

A: That's okay. The filter has no control over what frames VirtualDub will send it to analyse so the analysis runs through all frames. The filter only analyses the specified ones, however. All the other frames are just skipped.

Q: What's wrong with deleting frames in the video?

A: Don't delete frames in the video if you intend to specify the frame numbers for processing or if you want to run an analysis of the video stream. At first, the filter doesn't have access to frame numbers as you see them on the VirtualDub's main vindow and it only refers to the original video frames, i.e. frame numbers in the complete video stream. For instance, if you have deleted frames 1000-1099, the frame 1000 as you see it will be frame number 1100 for the filter. Unfortunately, it's not all. VirtualDub 1.4.10 (and possibly older versions too) contains an error in the sampling routine causing it to apply the frame deletion two times, causing completely different frames to be analysed - sometimes even the deleted frames. Therefore, deleted frames in the analysed video may lead to unwanted results even without specifying frame numbers!

Q: The filter displayed an error message. What does it mean?

A: See the Error messages section

Q: The filter closes the Preview window whenever I press any Save or Load button.

A: This behavior is intentional because the save/load dialog box insisted on opening itself behind all the VirtualDub's windows whenever the Preview window was open.

Q: Do I need to run the analysis process to remove an opaque logo?

A: You don't have to run the analysis but you can use it to find the actual logo shape. You can use the Alpha mask instead of a saved frame as a base to draw the Repair mask.

Q: I have loaded a mask to the filter and the filter still does nothing.

A: Check if the mask size is the same as the video image size. In case of difference, the filter loads the mask but it doesn't use it.

Q: The repair process is very slow.

A: Due to the nature of the repair algorithm, it is the slower the bigger the repaired area is and the more pixels are in the border area. This dependence is not linear but rather quadratical (repaired pixels times border pixels). To speed it up you can try to reduce the border depth, reduce Pixel aspect and check the Interlaced box. You can also try to split the repaired area to more regions when the removed logo is not continuous.

Q: Does DeLogo support batch processing?

A: Yes, the batch processing is fully supported. There are some problems however - there is no way to store whole masks to the batch file so all masks must be saved somewhere first in order to be loaded at batch run. Also the filenames and paths should be short enough to fit to the 512 characters long configuration line at once.

Q: Is the filter optimised for my processor?

A: There are no MMX, SSE, 3DNow! or other processor specific optimisations in the filter. There is no assembly language in the filter because I don't know it. On the other hand, there are as many precalculations done as possible to speed up the process itself.

Q: I have some other question.

A: Mail me to kasuha@post.cz.

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

Jean-Francois Pirus for bug reports/fixes