View Full Version : Remove antialiasing from Subtitle
RGMOfficial
20th December 2022, 14:35
I'm trying to do an simulation of analog test text on-screen, but there's a problem:
I need to remove the antialiasing from the text, but i don't know how.
Can you guys help me?
ColorBars(width=640,height=480,pixel_type="YUV444").ChangeFPS("ntsc_double")
text = BlankClip(last, pixel_type="YV24", color=$000000, width=(StrLen("01:00:58:00")*13)*2, height=20*2).ChangeFPS(FrameRate(last)/2)
text = text.ShowSMPTE(offset="01:01:00:00",font="VCR OSD Mono",text_color=$FFFFFF,halo_color=$FFFFFFFF,size=21*2,y=18*2)
text = text.ChangeFPS(FrameRate(text)*2)
#text
SeparateFields()
text = text.SeparateFields()
Overlay(last,text,x=(width()/2)-(width(text)/2),y=height()-48)
Weave()
LanczosResize(720,height())
https://i.imgur.com/cnMh7bG.png
Emulgator
20th December 2022, 17:47
ShowSMPTE() is based on Subtitle(), and yes, Subtitle() renders with antialiasing out of the box.
Maybe this Avisynth internal filter could be recompiled to make antialiasing switchable,
but can also be that the underlying function CreateFont() (Visual C++) already has this baked in ?
DTL
20th December 2022, 19:37
To skip most of AA you can rasterize in higher size (like 3..10x larger) and PointResize() to required output size.
Something like
text = text.PointResize(text.width*10, text.height*10)
text = text.ShowSMPTE(offset="01:01:00:00",font="VCR OSD Mono",text_color=$FFFFFF,halo_color=$FFFFFFFF,size=21*2*10,y=18*2*10)
text = text.PointResize(text.width/10, text.height/10)
RGMOfficial
20th December 2022, 19:50
Thanks guys. :D
wonkey_monkey
20th December 2022, 20:56
That's no guarantee though - you still might end up with grey pixels. You could add this expr on it before downscaling:
expr("x 128 > 255 0 ?", "128", "128")
That font seems a little off though - the diagonal line on the 0 seems to leave a half-"pixel" gap which I'm not sure is accurate.
Emulgator
21st December 2022, 16:53
Yes, these suggestions together work beautifully.
Only the last LanczosResize has to go, because it introduces grey pixels again.
ColorBars(width=640,height=480,pixel_type="YUV444").ChangeFPS("ntsc_double")
text = BlankClip(last, pixel_type="YV24", color=$000000, width=(StrLen("01:00:58:00")*13)*2, height=20*2).ChangeFPS(FrameRate(last)/2)
text = text.PointResize(text.width*10, text.height*10)
text = text.ShowSMPTE(offset="01:01:00:00",font="VCR OSD Mono",text_color=$FFFFFF,halo_color=$FFFFFFFF,size=21*2*10,y=18*2*10)
text = text.expr("x 128 > 255 0 ?", "128", "128")
text = text.PointResize(text.width/10, text.height/10)
#text = text.ShowSMPTE(offset="01:01:00:00",font="VCR OSD Mono",text_color=$FFFFFF,halo_color=$FFFFFFFF,size=21*2,y=18*2)
text = text.ChangeFPS(FrameRate(text)*2)
#text
SeparateFields()
text = text.SeparateFields()
Overlay(last,text,x=(width()/2)-(width(text)/2),y=height()-48)
Weave()
#LanczosResize(720,height())
RGMOfficial
15th January 2023, 19:06
Oh, very thanks.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.