Figure 13: The Spectral Domain According To -tiletex. For the coefficient numbering notation, See A Revised Map
For those of you who took the scenic route, this is a summary of what you saw. For those of you who flew in from the first page, then this is the condensed version of what you might have seen 11 kilometers below, peeking through the clouds. Some things are left out, like the 1970's color television on the fritz and how it got that way. If what you read here seems strange to you, you can always follow the bouncing ball backwards.
Spectral art is about painting "wave strokes." Paint these by setting chiral pairs of coefficients inhabiting the spectral domain (Figure 13, left). The Fourier synthesis transfrom, wrapped inside of -tiletex, morphs these pairs into waveforms.
A chiral pair of spectral coefficients consists of two spectral domain elements that, under Fourier synthesis, produce component waveforms of identical frequency and orientation, these differing only in the handedness of their polarization: one rotates clockwise, the other counterclockwise.
These coefficients are both progenitors of the spatial waveform with the stipulated frequency and orientation, whose real and imaginary parts are each vector sums of the real and imaginary parts of the component waveforms.
Two images of identical dimensions represent the spectral domain. One holds coefficients' magnitudes, the other their phase angles. These become input images to -tiletex, the G'MIC script which interprets the image pair as a complex number field, the elements expressed in polar form.
-tiletex creates two output images, one called "Real" the other "Imaginary." When in doubt, issue "gmic -help tiletex in your favorite shell.
To set a particular waveform, locate an apt chiral pair. Aptness consists of a particular horizontal vibration, q, a particular vertical vibration, v, and a particular orientation: bend sinister (choose a coefficient pair, one from the upper left and one from the lower right quadrants), bend dexter (choose from the lower left and upper right quadrants) vertical (choose two from the upper and lower halfs of the middle pixel column), and horizontal (choose two from the left and right halfs of the middle pixel row).
Four coefficients can't be paired and produce unique outputs. The Zero Pole (ZP), in the exact middle of the spectral domain, adds or subtracts a uniform bias to the output images (a "zero frequency" signal). The Nyquist Pole (NP), upper left corner, applies the highest possible frequency horizontally and vertically (a one pixel checkerboard). The middle pixel on the top row applies the highest possible frequency vertically. The middle pixel on the left hand column applies the highest possible frequency horizontally. If you want one of these four unique waveforms, just pick the single appropriate coefficient. Otherwise you'll choose a chiral pair of coefficients and manipulate them in tandem.
Locate coefficients q and v by counting off q horizontal and v vertical pixels from the Zero Pole and into each of the quadrants apt for the orientation you want. A coefficient's horizontal and vertical offsets from the spectral origin, q and v, establish both the orientation and frequency of the resulting waveform.
These offsets fix a right triangle; The waveform's propagation direction coincides with its hypotenuse. The frequency at which the spatial waveform oscillates along a horizontal line is exactly the coefficient's horizontal offset from the spectral origin, q, similarly for the vertical, v.
Having located coefficients for chiral pair q:v, set each of them to some value. That value is complex, having magnitude and phase angle parts. Physically, a coefficient is represented by one pixel from the Magnitude image and one pixel from the Angle image, at offsets q:v from the middle pixel of each image.
Magnitudes are straightforward. They range in value from 0 to 255. Zero turns coefficients off; the phase angle is then immaterial. While the magnitude sets the overall "brightness" of the waveform, a curious angle called θ (see below) apportions this brightness between the real and imaginary output windows.
Phase angles implicitly set two inferred angles. One, θ, ("theta") apportions the wave form between the imaginary and real output images. The other, α, ("alpha") controls the phase angle. This diagram furnishes a geometric interpretation of these two angles.
For θ and α, set the phase angles of both coefficients in tandem.
For those who don't mind a little bit of mathematical notation:
where ∠C is the phase angle value of the righthand coefficient, ∠C' is the phase angle value of the lefthand coefficient.
Differences in the magnitudes of the two coefficients, ΔC, dampen the actions of θ and α. When the magnitude of one or the other coefficient is zero, θ and α cease to have any effect. The composition of the real and imaginary output images tend to diverge as ΔC increases.
Since gmic natively works in 32 bit floating point, one can generally use -set or -point to set precise coefficient values for “Magnitude” and “Angle” images, values that may be negative if that is what the exigencies of a particular waveform require.
Most prefer the interactivity of a paint program to prepare “Magnitude” and “Angle” images. However, This places some numeric limitations on the work. For the canonical unsigned, eight bit paint program, one cannot exactly set angles or magnitudes, because values round to the nearest of 256 integral bins. Nor can one expressed negative angles.
Fortunately, not a great deal of generality is lost if one works with a base value of θ = 180° which maps approximately to the pixel value of 127. The consequence of this is that your waveform starts off inverted; most likely, you won't care (See Bisector As Balance Control). It is not an uncommon preparatory step to flood-fill the “Magnitude” image with pixel value 0 (black) and the “Angle” image with pixel value 127.
When setting angles, degrees do not quite equal pixel steps; a single pixel step equals about 1.41176.° Magnitudes vary from 0 to 255.
To paint waveforms with an eight bit, unsigned paint program:
Feed your magnitude and angle images to -tiletex:
gmic \
-input magnitude.png \
-input angle.png \
-tiletex[-2,-1] \
-round[-2,-1] 1e-6 \
-normalize[-2,-1] 0,255 \
-output[-2,-1] textures.png
A progression of concepts portrayed here, from simple to complex:
Real | Imaginary | |
---|---|---|
1. Input | ||
1. Basic and Boring: q=4, v=3. There are four horizontal cycles, three vertical. Magnitude of both coefficients is 255, angular settings of both is about 180° (pixel value = 127). Since both coefficients have equal angular settings, the phase offset α is necessarily equal to 0° and that θ = 180.° Because θ = 180°, the waveform appears fully in the real image, leaving the imaginary black, but is inverted: a trough commences the wave train in the upper left hand corner instead of a peak. Because α = 0° the upper left hand pixel coincides with the minimum value in the trough. | ||
1. Output | ||
2. Input | ||
2. Changing θ: The angular values of the two coefficients were both changed to pixel value=63, an offset of about 90.° Both coefficients still have equal angular settings which necessarily means that phase offset α = 0.° With θ ≈ 90,° the waveform shifts entirely from the real to the imaginary image and is no longer inverted. A peak commences the wave train in the upper left hand corner instead of a trough and because α = 0.° there is no phase shift; the peak coincides with the pixel in the upper left hand corner. |
||
2. Output | ||
3. Input | ||
3. Changing θ and α: coefficients now have different angular measures. The first has a pixel value of 50, the second a value of 127 implying a non-zero α. The two rules are (1) that θ is halfway between the bracket values of 50 and 127: 50 + ½ × (127 – 50) ≈ 89, or that θ ≈ 88.5 × 1.41176 ≈ 125° (there are about 1.4° per pixel increment). (2) The size of α is one half the difference between the bracket values. ½ × (127 – 50) = 38.5, in degrees: 38.5 × 1.41176 ≈ 54° With θ ≈ 125,° ten degrees closer to 90° than 180°, the imaginary image has a slightly greater proportion of the waveform than the real image. Because 125° lies between 90° and 180° the real image of the waveform is inverted, the waveform starting in a trough, but the imaginary image of the waveform is not. Both images reflect the phase offset of α; they have shifted 54° degrees, about 38 pixels. Compare with output panels 1 and 2. |
||
3. Output | ||
4. Input | ||
4. Multiple Chiral Pairs: Apart from elucidating underlying principles, one does not usually engage in such precise measuring for producing single waveform tiles. What we have been doing is learning to sail a boat in a nice well-sheltered harbor, trying one sheet, then another, and experimenting with the tiller. With that done, We now have all sheets to the wind and, for better and worse, we are on the high seas. This fourth demonstration is more in keeping with -tiletex's intent, that of rendering a small (or largish) collection of spectral domain coefficients. Here we have made an informed (but not precisely calculated) settings of 8 chiral pairs. It may not seem that all necessary coefficients have been given non-zero values for 8 pairs; but recall that only one coefficient of a pair needs to be set. The other, though of zero magnitude, still has a computational presence. | ||
4. Output | ||
5. Input | ||
5. Let there be a (little) color: Introducing color is straightforward and does not require a boatload of theory. -fft and -ifft regard the channels of mult-spectral images as so many independent processing pipelines. This present example is almost the twin of 4, but we have colorized to a fairly low saturation the angular components of the coefficients. From -ifft's prospect, this looks like three independent transforms with identical magnitudes but perturbed angles. Variations in α give rise to rainbow-like effects as waveforms are shifted along their axes to different degrees in each color channel. Variations in θ change how a waveform apportions itself between imaginary and real images; variations from one color channel to the next can be quite dramatic, even for mute colors in the coefficients, because a particular θ happens to be near one of the cardinals in one of the channels, making that channel dominant in just the imaginary or real channel. | ||
5. Output | ||
6. Input | ||
6. Let there be a (lot of) color: Setting all or most coefficients to some dominant color, perhaps red, does not lead to tiling patterns that are predominantly red; half the waveform's cycle tends toward the complementary color. For that matter, keeping coefficients low in saturation will not, necessarily result in a texture that is generally unsaturated. There is also the matter that for large α color will actually decrease. See Phase Control and the figure that goes with it. | ||
6. Output | ||
7. Input | ||
7. Zero Pole Coefficient: Coefficient 0:0 is remarkable in that it doesn't pair-off with any other coefficient. Sitting at the intersection of horizontal and vertical reflection axes, it essentially reflects to itself. It is also remarkable in that the waveform it encodes has an infinite wavelength and a frequency of zero. In practical terms, this coefficient represents the average intensity of the spatial image, what electrical engineers of a certain age and era call the “DC (Direct Current) Level,” as all other coefficients encode alternating currents of various stripes and persuasions. For texture-making purposes, it is the one coefficient that can impart an overarching hue, as all other coefficients tend to alternate between two complementary hues that average to gray. | ||
7. Output |
Suppose one envisions a wedge of cheese and antipasto and, without a picture to morph into the spectral domain, proceeds to make an image solely by apt choices of coefficients. Oh, perhaps about three million of them.
It is likely that the work will be interrupted somewhere in mid-course by the complete exhaustion of Sól's hydrogen reserves, and her subsequent expansion into a red giant, encompassing the third rock out. The artist will be obliged to cease for awhile to locate a new planet, a vexing annoyance. It is probable that the room full of chimpanzees randomly banging on typewriter keys will have reproduced the complete works of Shakespeare before the spectral painter has worked his way forward to a yellowish, fuzzy blob. It is slow work, this spectral painting.
However, on the very limited ground that we have covered, setting small numbers of coefficients here and there, profit can be found. The main advantage is that the textures, based on periodic waves, are themselves periodic and can seamlessly tile a surface. The textures themselves assume great variety and interest with less than a dozen coefficients and readily grow in complexity with just a few more.
This arises because the artist has a number of parameters which, in various permutations and combinations, lead to an incomprehensible number of courses. Indeed, it is the size of this thicket that makes navigating to a particular result so vexing. But if one has sufficient peripheral vision to spy beauty on the way, the aspect of not being able to arrive at a particular place is not the drawback that it seems.
The map is still not complete, but they never are and it is time to go. Take it for what it's worth and good luck on your journey. Send us post cards.
Coefficient Values: Part Three | Appendix |