Saturday, December 3, 2011

Synthetic Test Subjects

Been quite busy lately, so not much time to write here.  Recently, though, a work colleague brought up a hobby project that touched on geodesic dome geometry, which is something I've played around with a bit and had been intending to explore here.  That's prodded me to take find a little time to write another post or two.

The programs I've written dealing with geodesic dome geometry make a lot of use of projection via affine transform.  Basic stuff, but I think interesting and visual in itself and often poorly explained.  So I might write up a post or two and put together a couple of web toys just dealing with that as some groundwork, before moving on to anything having to do with geodesic domes directly.

A web toy dealing with projections/mapping/warping needs a visual test subject.  A usual approach is to take a sample bitmap and show the result of running it through the transform.  This can produce less than appealing results, because of the inherent limited resolution of the source bitmap.  Depending on the transform, very small (subpixel) areas of the source image can end up taking up very large areas of the result image.  Intermediate pixels then need to be synthesized/interpolated, and the results get bumpy/blurry.

I find it more convenient to deal with a synthetic, functional, test subject.  Given a point (x,y) in the real image plane, a function is invoked to return the color of that point in test subject.  This sort of test subject can have effectively infinite (within the limits of floating point) resolution.

Since the test subject has effectively infinite resolution, it is also easy to oversample the source with respect to the output bitplane and then average the sub-pixel results to obtain a greater effective visual resolution.

Code for a synthetic test image need not be complicated.  Here are some coded synthetic test subjects in just a dozen or so lines of JavaScript each, and also a couple functions to oversample and render the results (hosted at; click the "+" button to go offsite and explore the code).

I'll be using these test subjects in subsequent articles to illustrate the effects of transform math.