Project Ideas
Summary:
You've already learned about a number of basic techniques that you can
use in making images, including region-based color blends, string art,
and even the basic GIMP tools. In this reading (and the
corresponding lab), we will consider a few more techniques that you
might find useful.
Color Trees, Revisited
In the reading
on trees, we encountered an interesting way to use
trees: We can represent an image with a color tree,
a tree whose leaves are all colors. We can then render the tree
systematically. In that first rendering algorithm, when we encountered
a pair, we split the image (or subimage) horizontally and then rendered
the left half of the tree in the left half of the image, and the
right half of the tree in the right half of the image.
It can be more interesting (and more valuable) to render a color
tree by alternately decomposing the image horizontally and vertically.
The following alternate definition does just that. (You may find
it valuable to study it for a moment.)
How can color trees be useful for the project? Well, if you're willing
to put up with fairly unpredictable
images, you can write
a procedure that systematically builds a color tree from an integer.
But how do we build an interesting color tree?
One strategy is to look at some characteristic of the number (e.g.,
the remainder after dividing by ten) and use that number to decide
how one might split the number (e.g., if the remainder is 1 or 2, we
build a color tree whose left subtree is built from some fraction of
the number and whose right subtree is built from some other fraction
of the number. If the remainder is 3 or 4, we build a color tree
whose left subtree is a different fraction, and so on and so forth.
Here's an implementation of that technique.
Here's one way to incorporate that procedure into a
series of images.
You'll have a chance to explore these ideas a bit more in the lab.
Fractals
Color trees provide one way of decomposing and then rebuilding
an image. But, at least as created using the techniques above,
they create unpredictable images. As we explore in this section,
one can more systematically build an image by decomposing it into
smaller pieces.
A mathematically interesting kind of drawings is what
is commonly called a fractal. Fractals are
self-similar drawings. That is, each portion of the drawing bears
some resemblance to the larger drawing. We normally draw fractals
by breaking the larger drawing into equal portions and drawing each
portion using the same technique.
For example, to draw an NxM rectangle, we might draw nine
(N/3)x(M/3) rectangles in a grid. Similarly, to draw each of
those nine rectangles, we might draw nine (N/9)x(M/9) rectangles,
and so on and so forth. When do we stop? When we've recursed enough
or when the rectangles are small enough.
We might express this technique in code as follows.
Why would we use such a technique, since all we end up with is the same
rectangle? Well, things get a bit interesting when you make subtle
changes (other than just the level of recursion) at each recursive call.
Most typically, you might draw the different subrectangles in modified
versions of the original color. Once you do that, you can also think
about changing whether or not you use an even grid, or even whether or
not you draw each sub-rectangle.
The technique sounds simple, but it can produce some very interesting
images. More generally, fractals also let us provide interesting
simulations of many natural objects, such as trees, mountains, and
coastlines, that have some of the same self-similarity. We'll start
our explorations with these rectangles.
What can we do? Well, instead of drawing all sub-rectangles the same
way, we can vary them a bit. For example, we might draw some of the
sub-rectangles in the complement of the color, in a lighter version of
the color, or in a darker version of the color. We might break up
the rectangle into a less even grid. We might use different levels of
recursion for different sub-rectangles. We will explore these kinds of
options in the corresponding lab.