PDA

View Full Version : How to render text in 4 color with high quality


d2mp
6th October 2006, 02:15
I've been feeding dvdauthor's spumux with SRT files but the resulting rendering quality is very bad.

So, I've decided to develop a Delphi application to receive a SRT (subtitles) file and output .PNG compatible image files with high quality for subtitled dvd authoring.


I've tried some of the nice anti-alias and outline algorithms in thread:
http://forum.doom9.org/showthread.php?t=82155

Unfortunatelly, these algorithms produces image files with 6 to 12 colors, which is not acceptable for dvd authoring: maximum is 4 colors.

I've developed a function to reduce the colors to 4, but the resulting rendered text is very "unsmooth".

I know that there should be a way of high quality rendering text in to 4 colors bitmaps/png (DVD Maestro, Adobe Premiere and DVD Lab, can do it), but I'm out of ideias.

Does someone has an hint for this?


Thank's

unmei
13th October 2006, 04:46
A problem i see with relatively small text in what is bascly 1 color vs 1 background, or with at most 1 more color for antialising is that only horizontal and vertical lines look nice. The best results can probably be achieved by modifing the way the font is rendered (modifing the curve descriptions) to get as many of those lines as possible. Or only use fonts already designed for this application.

If you already recieve "bad" bitmaps from the font rendering, it is very hard to clean up. An approach that may work to some point may be opening-closing or something like pruning, basicly shave off pixels that stand out. But that can't help against slanted lines, they will always look worse than if your font already generated orthogonal (vertical/horizontal) lines.

PS
While that thread indeed is a nice reference, as you also found, you probably cannot use normal antialiasing methods, they will just not look good with that few colors. In my experience you need about 8 colors minimum (bgd,outline,font +2*2 for aa, 1 spare) and around 16-32 it is almost as good as true color. At 4 colors you need different approaches (not just optimizing color choice in normal AA).

d2mp
15th October 2006, 22:47
Yes. It is quite a difficult task.
But since 4 colors and 720x576 is the best that DVD Standard accepts to subtitles, there aren't many alternatives.

Authoring programs like DVD Maestro, DVD-LAB or Adobe Encore, already produces a very good output, so there are ways of resolving this issue.

I've wrote a simple algorithm to outline text with 2 or 3 passes, finding the limits of the font edges (this is a lot better than making a windows "path" with a "pen").
Once the result is to be displayed in TV-SETS (the primary DVD players output with a low resolution) the result is already quite acceptable.

Nevertheless the resulting subtitles are still a little bit crispy.
This is quite noticeable with the letters with upper and lower coners like "a e c s" and similar.
The testing was made with ARIAL bold fonts.

I believe the next steps will be:
- to find the best fonts for subtitle rendering (something larger than arial but with a thinner stroke);
- develop a new algorithm that smoothes the font edges without anti-aliasing (which is not compatible with low color depths).

Darkmoon_UK
14th November 2006, 19:00
4 Colours, luxury! When I were a lad we had to anti alias by pulse modulating a single bit at only 5 frames per second with our eyes squinted for effect!

Joking aside, I've never considered this a very tough task. I find Macromedia Fireworks the best for rendering text, though I feel sure you could do the same with Photoshop. I give the text a touch of blur usually around 1 gaussian. Then reduce to 4 colours using dithering, and a pallete which evenly splits the luminosity range... 0, 79, 179, 255.;)

kumi
14th November 2006, 19:37
The first problem here is your choice of typeface: Arial is extremely unsuited to low-resolution rendering... it's generally a horrible choice for any type of captioning, in fact.

http://screenfont.ca/fonts/today/interim/

Take some time to experiment with as many different typefaces and font-families as you can get your hands on. And I mean you should actually render the fonts in your DVD subtitling app of choice. Remember also that font-sizing at low resolutions is finicky: at 20px the kerning or characters might look 'distorted', but look perfect at 19px.

Personally I've settled on a mild slabserif for my subtitling. It's very readable:

http://img300.imageshack.us/img300/2816/maestrosbt0056is.png

(rendered by MaestroSBT)

d2mp
14th November 2006, 20:24
For anti-aliases, all tests made at 4 colors (even with photoshop) resulted in lower quality than without anti-aliases.

In fact, a good outlining is the best thing for viewing in TV-SETS: too little gives flickering effects and difficulty reading in lighter backgrounds; too much it's just not nice; but using 2 or 3 lines gives just the good text contrast, and flicker free.

Another important thing is the spacing between characters. The default windows rendering is just to "tight" for easy TV subtitle reading.

About font. Well, it is always a personal thing, but I've picked up Arial Narrow (not arial), NOT bold, forced a windows character spacing of "2" and my own outlining algorithm with "3" lines.

I can say the result is quite acceptable. I say this not only compared with the results of most DVD authoring software (with rendering capabilities), but also when compared to "Professional" authored DVD movies bought in the market.


[I will prepare a screen shot and post it]

JohnnyMalaria
14th November 2006, 21:15
http://screenfont.ca/fonts/today/interim/


<RANT>

Out of curiosity, I looked at this site. Good grief! Talk about pedantic!

They have a gallery of what are supposed to be bad examples of captioning. In particular, the UK and Australian Teletext samples are cited for various mistakes. But they are NOT mistakes. They follow the specifications for Teletext subtitling. For example, there is a recurring complaint about using the # character to indicate singing rather than a staff note. Who is to say that is wrong? And the use of coloured subtitles to distinguish which character is speaking. Again - who says that's wrong.

I grew up with Teletext so I fully understand the nuances of the subtitles. I expect UPPER CASE to describe non-spoken events (e.g., DOOR SLAMS SHUT instead of Door slams shut).

</RANT>

HyperHacker
21st November 2006, 11:17
Coloured text would be a problem for colourblind people. Other than that, I agree with you. It's usually easy enough to tell what text means what from context anyway.