View Full Version : Using DeKafka for removing hardburned subtitles question
i played around with dekafka (http://www.avisynth.org/index.php?page=DeKafka) for removing hardburned subtitles
i somehow dont really get what the sense of substracting -2 in the following lines is (and why ybot and xright dont get 2 removed too):
topline = clip.Crop(Xstart-2, ytop-2, X, 2)
bottomline = clip.Crop(Xstart-2, ybot, X, 2)
leftline = clip.Crop(xleft-2, ytop-2, 2, Y)
rightline = clip.Crop(xright, ytop-2, 2, Y)
especially the top/bottomline -2 is strange, as it leads to that the output overlayed picture is moved to the right for 2 pixels and therefore not being "in sync" anymore with the underlying picture by 2 pixels
i adopted the script for not having to provide a maskclip and for not having the pic moved to the right for 2 pixels:
function dekafka(clip clip, int Xstart, int Ystart, int X, int Y, int Amount)
{
ytop = Ystart
ybot = Ystart + Y
xleft = Xstart
xright = Xstart + X
topline = clip.Crop(Xstart, ytop-2, X, 2)
bottomline = clip.Crop(Xstart, ybot, X, 2)
leftline = clip.Crop(xleft-2, ytop-2, 2, Y)
rightline = clip.Crop(xright, ytop-2, 2, Y)
logosrc_hor = StackVertical(topline, bottomline).Blur(1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58).BilinearResize(X, Y)
Amount2 = (Y>=2*X) ? 255 : 128*Y/X
# Amount2 is small if X >> Y => logoscr_hor is dominant
logosrc = Layer(logosrc_hor, logosrc_ver, "add", Amount2)
clip = clip.Layer(logosrc, "add", Amount, Xstart, Ystart)
return clip
} anything wrong with that?
ppera2
22nd May 2005, 13:12
See this: http://forum.doom9.org/showthread.php?s=&threadid=94711
There is small error in Dekafka beside that shift, for example at blurs - it should be so:
logosrc_hor = StackVertical(topline, bottomline).Blur(0, 1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58, 0).BilinearResize(X, Y)
But, I think that blurring does not much impromevent. And is buggy in YUY2.
In case of covering subtitles, I think that no need to crop left and right sides. Script would be like this, but I make it 'on fly' :)
function desubt(clip)
{
#Position & size & Opacity - enter here values by subtitle position and size
Xp = 88
Yp = 288
X = 448 #Must be dividable by 4
Y = 66
Op = 255
#By need:
#clip = clip.ConvertToYUY2()
top = clip.Crop(Xp, Yp-2, X, 2)
bot = clip.Crop(Xp, Yp+Y, X, 2)
#logoh = StackVertical(top, bot).BilinearResize(X, Y)
logoh = StackVertical(top, bot).Blur(0.2, 1.58).BilinearResize(X, Y)
#logoh = StackVertical(top, bot).ConvertToRGB32.Blur(0.2, 1.58).BilinearResize(X, Y).ConvertBackToYUY2()
clip = clip.Layer(logoh, "add", Op, Xp, Yp)
return clip
}
In case of green artifacts by blur use line above or line under, where colorspace is temporarely converted to RGB, only because of blur.
hi ppera2, thanks for your answer and tips :)
In case of covering subtitles, I think that no need to crop left and right sidesgood idea, to not need StackHorizontal for removing subs :)
two things on your comments on blur():
But, I think that blurring does not much impromevent. And is buggy in YUY2i do think that using blur is very useful for removing subs (or other big parts of the picture), as when not using it (or another blurrer) the top and bottom half of the picture dont get mixed and therefor you can very easily see the border between the two, which looks very ugly and "unreal", not fitting in the picture imho
when using blur the transition is more smoother and the filtered part fits more the rest of the picture
There is small error in Dekafka beside that shift, for example at blurs - it should be so:
logosrc_hor = StackVertical(topline, bottomline).Blur(0, 1.58).BilinearResize(X, Y)
logosrc_ver = StackHorizontal(leftline, rightline).Blur(1.58, 0).BilinearResize(X, Y)for the purpose of removing subs i think that blurring only vertically, makes the filtered part also looking wierd (the part where the subs were, shows than spaghetti-like lines)
i would say that therefore a full vertical blur with a slight horizontal should be used (as tradeoff between smoothing too much and reducing line-creation) for removing bigger parts of a picture, like in the case of subs removal
In case of green artifacts by blur use line above or line under, where colorspace is temporarely converted to RGB, only because of blurhm is this a known bug in blur()?
i mean using rgb would have the advantage that you can also choose the to-be-removed part more accurately, as you can than crop also in steps of 1
does converting to rgb (and back again if necessary) really take that much extra time?
lemme modify the script the following way:
function DeSubt(clip clip, int horizontal_position, int vertical_position, int width, int height)
{
clip = clip.ConvertToRGB()
top = clip.crop(horizontal_position, vertical_position-2, width, 2)
bottom = clip.crop(horizontal_position, vertical_position+height, width, 2)
mask = StackVertical(top,bottom).Blur(0.5,1.58).BilinearResize(width,height)
clip = clip.Layer(mask, "add", 255, horizontal_position, vertical_position)
return clip
}i renamed the values to be more representing, the values dont need to be set in the script itself anymore, increased the blur, added converttorgb (why does X/width always have to be dividable by 4?) and removed ConvertBackToYUY2(), as this backconversion doesnt have to be necessary always
ppera2
22nd May 2005, 18:30
Blur improvents visual quality, but by my opinion just slightly, so it's matter of taste - use it, and how much blur.
I observed artifacts only by YUY2 blurring, and it's best viewable on B/W captures. Maybe should to contact AVS development team about it...
I looked for some external blur filters, but didn't find usable until now.
Reason why I modified DeKafka is right RGB conversion. It slows it, because whole clip is converted. When converting only mask part it is much less CPU time consuming. Other reason was that colorspace conversions make some color distorsions.
Don't see that unablity to use odd values by YUY2 is big problem - one line more means nothing.
And: how long names using in scripts (programs) is also matter of taste. I don't like too long names, but like long comments (not to write :D )
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.