Pixelated text in figures using text() function
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hrefna
el 3 de Feb. de 2015
Comentada: Mike Garrity
el 6 de Feb. de 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 comentarios
Chad Greene
el 3 de Feb. de 2015
I've noticed this too. The "improved" graphics of R2014b also make circle 'ro' markers look awful.
Respuesta aceptada
Hrefna
el 4 de Feb. de 2015
3 comentarios
Mike Garrity
el 6 de Feb. de 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.
Más respuestas (1)
Mike Garrity
el 4 de Feb. de 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.
Ver también
Categorías
Más información sobre Graphics Performance en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!