Pixelated text in figures using text() function
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hrefna
am 3 Feb. 2015
Kommentiert: Mike Garrity
am 6 Feb. 2015
Hi,
The text() function when adding text to figures seems to me misbehaving. The text is noticeably pixelated when compared to all the other figure text, both on my monitor, and also when I print out to jpg, see
Any hints about settings that could fix this? How do I make the text look more like the default figure text? The pixelation becomes glaringly ugly when projected onto a big screen.
2 Kommentare
Chad Greene
am 3 Feb. 2015
I've noticed this too. The "improved" graphics of R2014b also make circle 'ro' markers look awful.
Akzeptierte Antwort
Hrefna
am 4 Feb. 2015
3 Kommentare
Mike Garrity
am 6 Feb. 2015
That'd actually be very tricky to implement.
In some ways the real issue is in how FontSmoothing is implemented. It's different from how GraphicsSmoothing is implemented. GraphicsSmoothing uses a technique called MSAA. This actually figures out what portion of the pixel is covered by the different primitives that touch it. This correctly handles some of the hard cases, but it gets very expensive as the number of samples gets large. We use it for most graphics primitives because it prevents artifacts like the white lines you see between abutting polygons in apps like Adobe Reader which use simpler anti-aliasing techniques.
FontSmoothing uses a simpler technique which just uses the coverage percentage for each primitive that touches the pixel. It's usually good enough for text because you usually don't have multiple text strings touching the same pixel. But, as you see it, it can fail in some situations.
It's unfortunate that text doesn't look good with GraphicsSmoothing='on' and FontSmoothing='off'. The reason for this is that GraphicsSmoothing needs "sub-pixel information", and the way fonts get rasterized eliminates that.
Weitere Antworten (1)
Mike Garrity
am 4 Feb. 2015
There are an awful lot of variables in play during font rasterization. I'd have to know a lot more about what you're doing. Here's the closest I was able to get by guessing:
figure
h(1) = plot(randi(10,[1 40]),55+40*rand(1,40),'ro')
hold on
h(2) = plot(randi(10,[1 40]),55+40*rand(1,40),'bx')
t(1) = text(1.5,83,'text(1.5, 83, ThisTest and ABCDEFGHIJKLMNOPQRSTUVXYZ)')
t(2) = text(1.5,62,'text(1.5, 62, ThisText and abcdefhijklmnopqrstuvxyz 123456789)')
ylabel ylabel
xlabel xlabel
set(h,'LineWidth',2)
t(2).FontSize = 16
grid on
legend('Red Legend','Blue Legend','Location','SouthEast')
set(gcf,'Color','white')
l = line([1 10],[80 80],'LineWidth',2,'Color','black')
print -djpeg -r150
Which results in the following on my windows box:
If you zoom in on the two images you'll see that they're close, but there are some artifacts in your text which aren't in mine. If I guessed reasonably closely, I would wonder about things like:
- What platform (windows, linux, mac) you're on
- Whether you've got unusual fonts installed
- What 'opengl info' says
- What get(0,'ScreenPixelsPerInch') says
But there are lots of other variables to consider. It looks like you've got GraphicsSmoothing and FontSmoothing turned on, is that correct? This looks like Helvetica, is that correct? Are you seeing the same issue with other fonts? I assume that your figure's Renderer is opengl, although that shouldn't make that much of a difference in R2014b.
The reason I'm asking is that I'm planning to do some posts on the graphics blog about how text gets drawn, but it's a fairly complex area. I'd like to get an idea of what sort of issues you're really encountering in this area.
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!