Problems with Rasters
© 16 Jan 2014 Luther Tychonievich
Licensed under Creative Commons: CC BY-NC-ND 3.0
other posts

graphics

Aliasing, Visual Width, and Holes

 

Most descriptions of computer graphics include, fairly early on, a definition of a raster as a regular grid of pixels, where each pixel is (approximately) rectangular and holds (approximately) a single color. Some distinguish between vector and raster graphics, and a very few talk about pre-raster graphics techniques but I have yet to encounter one that discusses the good and bad of using a raster.

First, an aside about vector graphics. Storing a raster image is like storing a painting. of every brush stroke needed to create the painting. Storing a vector image is like storing a detailed list There is power in the vector representation, ability to change scale and modify things logically; but it still has to be turned into a raster image before we can see it.

Grids, Aliasing, and n-Connection

Why are pixels arranged in a rectangular grid? Because it makes algorithms easier and hardware simpler. There are bad parts to grids, though. In particular, they create many more chances for aliasing than would other cells.

I’m not going to go into details about aliasing; for this purpose the main thing to know is that the eye is really good at seeing straight lines. When pixels like up in straight lines, the eye sees those lines must more easily than it would if they were just kind-of lined up, scattered about a bit. When those grid lines don’t line up with the lines in the scene being displayed the interaction of the grid and the scene lines causes aliasing artifacts, things our eyes see that were not part of the intended scene.

Another problem with a square grid is the messiness of “‍adjacent‍”. How many pixels are adjacent to one pixel: 4 or 8? This may seem of no portent, but it has surprising implications including visually important things like the apparent weight of a line.. For example, the following raster has 3 lines of approximately the same length (5*sqrt(2) ≈ 7). The left one is 8-connected, the right one is 4-connected, and the bottom one, being horizontal, doesn’t need to decide between the two.

But notice the amount of black in each line: one has 5, another 7, and another 9 pixels of black. Whether you pick 4- or 8-connection, horizontal lines are differently bold than diagonal lines.

Shades of Grey

Both of the problems noted above about rasters can be mitigated by using partial shading. For example, we could fill in each pixel with a darkness proportional to the amount of “‍line‍” that passes through it:

This approach unifies the darkness of lines of all angles and removes most issues with aliasing as long as features are at least a full pixel wide; but it also adds a new problem when shapes overlap. Consider, for example, two shapes that meet along a shared line. Each one will let through some of the background color along that line, which means that although no background should be visible, some shows through anyway.

This existence of partial holes along the boundaries of two shapes is a very serious problem because much of computer graphics is based on breaking surfaces into many little adjacent triangles. If every seam has these kind of gaps, the object will appear to be perforated with little holes.

There are lots of compromises available. Two common ones are filling things in all-or-nothing but outlining them with shades of grey; or doing all-or-nothing shading on a much denser grid and then averaging boxes of colors into a single pixel before displaying. But they are compromises: the ideal is not achieved.

Alternatives

So, rasters are not a value-neutral choice. But what are the alternatives?

We could use a different tile: hexagons or triangles. But that would just change where the problems arise, not remove them.

We could use a Poisson disc distribution instead of a grid; then there’d be no lines in the pixels to alias with, though other sources of aliasing would remain; but writing graphics algorithms for that kind of display would be a nightmare.

We could go back to the days before rasters when you drew things by passing a stream of electrons across a florescent surface at various speeds and levels of focus; but that’s expensive, hard to program, subject to noise, can burn a hole in the screen, and has it’s own double-edge problems.

In other words, despite the problems they introduce, rasters are the best choice available.




Looking for comments…



Loading user comment form…