AlanHK Member
Joined: 25 Apr 2006 Location: Hong Kong
|
|
This guide explains how to remove an opaque logo using Xlogo in Avisynth.
Xlogo is an orphan application, apparently abandoned by its author, Leuf.
You can find the last version at Warp Enterprises here.
And this page archives that and the VirtualDub version. There is more explanatory material there, which applies to both versions, but the following should be sufficient for basic Avisynth usage.
This is an example of the kind of logo it can be used on:
Xlogo only needs one mask image.
It will try to extrapolate from the edges of the mask to fill it in, with imperfect results, but still I think the minimal effort makes a large improvement on an obtrusive coloured logo, and makes it barely noticeable.
We start by finding a frame such as the above, with the logo on a black background if at all possible.
Save a BMP screengrab from, eg, VirtualDub.
Open in your image editor.
I used Photoshop, but any other app will do.
Zoom in and crop around the logo as below:
Important:
1) Have at least 4 pixels clear black on all sides of the logo. If the surroundings are not 100% black, make them so (paintbrush, or use the magic wand selector and bucket with black).
2) Note the (x,y) position of the top left corner. Make both even numbers, and the width and height of the cropped area also even.
In this case, the position was (540, 300), width 64, height 24 pixels.
Now paint white over all the logo. The below shows the white as a separate layer, though you don't need to keep the original logo.
The result is :
Now save this black and white version as a BMP.
The name is important. Anything at the beginning (something related to the AVI file name) then "_x_X_y_Y_2" where the capital X and Y are the position (as above) the logo was cropped from (the "_2" at the end is mandatory). (Actually, the x,y in the name is not strictly necessary for the Avisynth version, but it makes it compatible with the VirtualDub filter.)
So in this case I save it as "logo221_x_540_y_300_2.bmp"
Now we can use this in our AVS script.
| Code: |
clip=AVISource("pb_221.avi",false)
clip.Trim(0,19) ++\
clip.Trim(20,0).xlogo("logo221_x_540_y_300_2.bmp", X=540, Y=300, alpha=0)
LanczosResize(720,480) |
The trims are to limit xlogo to specific frames of the video. Just omit the trim if you want it for the entire clip.
The first parameter is the logo mask BMP file, X and Y the positions again, and alpha=0 indicates a solid logo.
There are other parameters explained in the readme if you want to experiment, but I find the defaults are fine.
Open in VirtualDub to check.
You may see this error message:
This means there is a problem with the bitmap. First make sure the "black" surrounding the white logo shape is really black; if not, make it so. If you still get the error, it can also be caused by having the white mask too close to an edge. Enlarge the BMP to give some more black space around the logo (if you add pixels to the top or left, remember this will change the effective (x,y) position, and thus the name of the file and parameters in the function call).
If you see some remnant of the logo colour after filtering, enlarge the white mask a bit (just use paintbrush) in the affected area and try again.
Some examples:
Smooth areas of colour are almost perfectly repaired.
Very busy and detailed areas aren't so successful.
Note that some detail is restored here.
The alpha parameter
The previous example was solid colour -- the following has a little alpha transparency, not pure white as it at first appears.
(Notice the window frame visible through the logo).
Making a logo bitmap and using the parameters as for solid colour, we see a dark shadow on many of the frames after applying xLogo.
Original frame
Filtered with
xlogo("logo106_x_400_y_322_2.bmp", X=400, Y=322, alpha=0)
Filtered with
xlogo("logo106_x_400_y_322_2.bmp", X=400, Y=322, alpha=20)
Filtered with
xlogo("logo106_x_400_y_322_2.bmp", X=400, Y=322, alpha=30)
Filtered with
xlogo("logo106_x_400_y_322_2.bmp", X=400, Y=322, alpha=40)
As alpha increases the filtered logo area gets increasingly white.
Here I chose alpha=20 as the best compromise.
You could use the VirtualDub script editor for finding the optimum value, but I found the Avisynth script editor Avsp more convenient.
In this I used a slider for alpha:
xlogo("logo106_x_400_y_322_2.bmp", X=400, Y=322, alpha=[<"alpha", 0, 255, 10>])
And could quickly look at various frames with different alpha settings in different tabs.
Last edited by AlanHK on Dec 05, 2007 21:02, edited 6 times in total
|
|