G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
GREYC CNRS ENSICAEN UNICAEN

A Full-Featured Open-Source Framework for Image Processing



Latest stable version: 3.4.3 (2024/10/11)

Tutorial

From Wheelies, Arabesques

WheeliesInterludeDeep DiveFrom Wheelies, Arabesques
From Arabesques, WheeliesWheelie Animations

Let us combine wheelies:

\begin{matrix} \psi (t) = 0.375e^{i2\pi t} + 0.3125e^{i2\pi 3t} + 0.25e^{i2\pi 8t} & \textsf{E. 4} \end{matrix}

 7. A cardinal sum and the related arabesque

Equation 4 is a cardinal sum, an expression whose terms are wheelies. Separately, these terms each plot circles à la Figure 6 but in aggregate, plot more raveled arabesques. see Figure 7.

The three wheelies comprising Equation 4 are so chosen as to reproduce threewheelie. Figure 7 depicts its complex plane plot. The real and imaginary oscillations shown in the elevations are no longer sinusoids, but the combined partials of the three constituent wheelies.

In G'MIC, we can write such cardinals sums with Mathematical Expressions, using cexp(); see Threewheelie Redrawn.

Threewheelie Redrawn.
 1 cexpsum:
 2   size=255
 3   # complex parameter ramp plotted on the
 4   # imaginary axis.
 5   -input 360,1,1,2,'[0,(2*pi*x)/(w-1)]'
 6   -name. tau
 7 
 8   # evaluate a wheelie-sum
 9   -fill[tau] "0.3750*cexp(I)+
10               0.3125*cexp(3*I)+
11               0.2500*cexp(8*I)"
12 
13   # transform arabesque plots to a canvas
14   # drawing surface.
15   -fill[tau] "begin(
16                      sw=get('size');
17                      id=eye(3);
18                      id[0]=sw;
19                      id[2]=sw;
20                      id[4]=-sw;
21                      id[5]=sw
22                    );
23               (id*[I(x,y),1])[0,2]
24              "
25    # paint the arabesque plot points on a
26    # canvas: white on black.
27   -permute[tau] cyzx
28   -input {2*$size},{2*$size},1,1
29   -name. canvas
30   -eval "PV=crop(#$tau);
31          polygon(#$canvas,
32                  -int(size(PV)/2),
33                  PV,
34                  1,
35                  0xffffffff,
36                  255
37                 )"
38   -keep[canvas]

The gist of the computation, plotting an arabesque from three elements, begins with the construction of a complex number parameter range t, line 5 - 6, and its subsequent evaluation as Equation 4, line 9 - 11. In one fell swoop we obtain the plotting data set of the entire arabesque. The remainder is plotting-related housekeeping. With this entire data set in hand, we may call polygon() but once and pass it the entire plotting ensemble. Thus, we have amortized the set-up-and-teardown overhead of polygon() across all the plot points. Compare with gtutor_wheelie: this overhead was paid out for each plot point. We are on our way to a better gtutor_wheelie.

This cardinal sum exposes a conspicuous disconnect vis-à-vis threewheelie:

$ gmic                                                   \
   -command scripts/wheelie_simple.gmic                  \
   -input 512,512,1,1                                    \
   -name. canvas                                         \
   -gtutor_wheelie[canvas] 0.375,0,1,0.3125,0,2,0.25,0,5

Wheelies in the chain gyrate, from root to tip, at rotational rates f{1, 2, 5} Hertz (note third, sixth and ninth arguments):

simple_02
 8. What gives? This arabesque comes from wheelies with one, two and five rotational rates!

Yet with the cardinal sum, Equation 4, the rotational rates in each term's exponential argument are f{1, 3, 8}.

Both chain and sum produce the same arabesque, but seemingly from different frequencies. Further, we can reorder the terms of the cardinal sum in any way and the same arabesque obtains. Reorder links of wheelie chains, however, and different arabesques ensue.

Clearly, wheelie chains and cardinal sums are different quiddities, though both consist of wheelies. Can we fix what one is in relation to the other?

A back-of-the-envelope doodle brings forth a pattern:
11
1+23
1+2+58
The intrinsic orientation and rate of rotation of a wheelie in a chain — those measures with respect to its antecedent — do not reconcile with cardinal sums. But running sums do. In particular:

 1.  Both the wheelie chain and sum have the same root wheelie.
 2.  The second wheelie in the chain exhibits an intrinsic rotational rate of two Hertz. Its antecedent rotates an additional Hertz. Accounting for both intrinsic and antecedent rotations yields three Hertz: its rotation with respect to the coordinate frame. That reconciles with the second term of the cardinal sum.
 3.  Similarly, the third wheelie in the chain has an intrinsic rotational rate of five Hertz and picks up three Hertz from antecedents. That combined rotational rate of eight Hertz reconciles with the third term of the cardinal sum and reflects the wheelie's rotation with respect to the coordinate frame.

wheeliechainmap
 9. Walking from root to tip, accumulating rotations and orientations as we go.

Wheelie chains are ordered lists of differences, these encoded in delta wheelies, the constituent elements of wheelie chains. Delta wheelies register pairwise rotational and orientational changes between terms of an allied cardinal sum. Figure 9 illustrates.

To see how this is so, let's "walk the wheelie chain" from root to tip, recombining these differences as we go and, at the end, recovering the chain's allied cardinal sum.
 1.  Take a wheelie chain, start from the root and keep a running sum of orientations and rotational rates; tabulate these at each link.
 2.  For the first "root" wheelie, take the orientation and rotational rate as is; there is nothing that can be added to this initializer. It is a term of the cardinal sum as it stands.
 3.  For the second and subsequent n delta wheelies, add the orientation and rotational rate of the present delta to the running sums. With each addition, the running sums provide the orientation and rotation rate for an nth term of the cardinal sum.
 4.  The radial scaling for the nth term is just that of the nth delta wheelie. Thus, we find the cardinal sum from the angular differences encoded by successive delta wheelies, as first hinted by doodle; see also Figure 9.

Wheelie chains encode orderings of terms. Consider building a wheelie chain from a cardinal sum:
 1.  One term, arbitrarily chosen, is the root — or first — delta wheelie of the chain.
 2.  From there take the next, nth term of the cardinal sum.
 3.  Difference the (a) orientational angle and (b) rotational rate between the nth and n–1th cardinal terms. This initially orients the nth delta wheelie with respect to its n–1th antecedent and sets the ongoing difference in rotational rates between them.
 4.  Offset the nth delta wheelie from its antecedent by radius r of the nth cardinal term.
 5.  Resume with 2. if there are more terms, otherwise exit.

In making a chain, we proceed in whatever order we please with this differencing of cardinal sum terms. In so doing, we find that wheelie chains are not unique. Since the N terms of a cardinal sum can be ordered in N factorial ( N! ) ways, there are N! possible schemes to difference them and, following on, N! possible wheelie chains. Figure 10 catalogs the possible chains for a four-term cardinal sum: 4! ⇒ 24.

wheeliepaths
 10. Twenty Four ways (4!) to permute four cardinal terms

When we "wheelie walk" along a chain, we step off of one of the leaves (purple bullets) and follow one of N! possible paths toward the cardinal sum (red circle). Each path corresponds to a particular pair-wise differencing of cardinal sum terms following from one of their possible permutations.

Each path also corresponds to a wheelie chain, each providing one of N! ways to draw an arabesque defined from a cardinal sum with N terms. The key correspondence is between the arabesque and its defining cardinal sum. Off to one side from this key correspondence are wheelie chains, any one which can generate the arabesque through linked delta wheelies. Figure 11 depicts the case: an arabesque drawn by two different delta wheelie chains, each found from different permutations of the cardinal sum terms.

 11. Two chains, geometrically different, functionally equivalent, plotting the same arabesque

Previous:Deep DiveNext:From Arabesques, Wheelies

Updated: Sun 22-January-2023 22:22:58 UTC Commit: 846e5989e3a4
G'MIC - GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing

G'MIC is an open-source software distributed under the CeCILL free software licenses (LGPL-like and/or
GPL-compatible). Copyrights (C) Since July 2008, David Tschumperlé - GREYC UMR CNRS 6072, Image Team.