Figure 1: A Goudy 1911 Bookletter Ampersand dropping from a California Job Case

Blur by Color

The Blur by Color filter grows out of the "Do Your Own Diffusion Tensor Fields” series and if you're interested in coding G'MIC go read that first. In particular, the walk-throughs on Directional Blurring, and the preceding walk-throughs upon which this filter is based. We won't go into much of the theory here.

We were hesitant about writing this filter. There happens to be a bazillion ways to blur images in Gimp and its various plug-ins, at least seven filters in-Gimp-G'MIC plug-in itself – and who knows how many more may have been written out there in the wild. Why another?

Here's why. It is grounded on a generic, diffusion-based blurring engine – the G'MIC -smooth command – with a variable kernel that can be steered pixel-by-pixel with a tensor field. You don't need to worry about tensor fields: the takeaway is that you have very precise, pixel-by-pixel control over how your blur goes, and you will have a high quality blur.

The other blurring tools are fast. They're optimized for particular effects and if their aims fit your project run with them. However, if you want to craft how blurring takes place in a manner that no standard approach anticipates, then this blurring tool is the way to go. Essentially, you draw, or make some other image, into a blurring map. Drawing this map amounts to designing your own filter and you can specify blurring amounts and directions right down to the pixel level, should you so desire. Blur by color will never be fast. But it will be precise. And good.

How you make that map is up to you. There are two and a half approaches, painting the blurring map by hand, transforming a copy of the image in some way so that some aspect of the image itself controls the blurring process, or a specialized variation of making a map by hand, the contour method, where you just paint a few lines so that the blur follows the line contour. We did the bounce path of the Goudy Ampersand using this method.

Installation

Installing this filter is semi-automatic. It is distributed from the gmic.eu and all filters from that source can be downloaded and installed by using the refresh button (circular arrow) at the bottom of the Gimp-G'MIC plugin main dialog box. As of this writing, September 2014, the Blur By Color filter lives in the “Testing → Gmic Tutorials” branch, but may wander off into the main filter tree if it behaves itself and acquires friends. If refresh doesn't seem to be working for you, try checking with the usual gang of suspects.

Blur By Color Dialog Box

Nearly everything about custom-blurring an image is encoded in the blurring map. The filter itself has just two controls:

  1. Range: choice(“XL”, “VL”, “L”, “N”, “M”, “VM”, “XM”). Sets broad operating ranges for Amplitude, following. All ranges begin at zero. “XL”, extra light, sets the top end of Amplitude to 700, “XM”, extra maximum, sets the top end of Amplitude to 4,900; the intermediaries each add an increment of 700 to the top end of Amplitude. “N” (normal) ranges from 0 → 2800 and accommodates most typical work.
  2. Amplitude: float(0.5, 0.0, 1.0) Controls the overall effect of blurring. 0.0 disables blurring. 1.0 gives rise to extreme blurring. 0.5, the default is “just about right”, Range scales the abstract quantity of “extreme blurring” into one of seven working ranges.

Blur By Color needs to be able to find its blurring map, so in Gimp-G'MIC dialog box, under “Input/Output” (lower left, under the Preview pane) set the “Input Layers” to “Active Above” or “Active Below” – we like this latter setting because we tend to put control layers like the blurring map under the production layers. We also suggest setting “Output mode:” to “New Layer(s)” to preserve your blurring map. A lot of technique involves iterating over a “modifying the map, making a blur” loop as you increment your way over the finish line. And for people studying up on G'MIC code, we always suggest a “Very Verbose” message output, either to log or console.

If you get a preview error message with the cryptic phrase “Command 'local:' Invalid selection [-2,-1]…” followed by more cryptic stuff, then the filter cannot find its blurring map. You need to set Input Layers, or select the right layer – or perhaps actually create a blurring map.

So, how do you create a blurring map? It's just an image. It may be drawn from whole cloth, derived from your production, or a mix of the two.

There are three rules, one for each Hue Saturation Lightness channel, which govern how blurring goes.

Rules

  1. Hue controls direction.
    1. Every color has a blurring direction. The direction comes from the HSL/HSV color wheel with a “12 hour clock” orientation.
    2. Zero degrees is at the top (12 o'clock) and colors progress clockwise.
    3. Red corresponds to 0° and also 360°. Theoretically, it blurs from bottom to top (from center outward)

    4. Cyan corresponds to 180.° Theoretically it blurs from top to bottom, but for all practical purposes, this cannot be distinguished from red's bottom to top.
    5. A kind of lime green (127, 255, 0) corresponds to 90° and blurs from left to right.
    6. A kind of blue violet (127, 0, 255) corresponds to 270° and blurs from right to left (can't tell these apart, either).
    7. As a general rule, if you know a color's degree angle in HSL/HSV notation, that's the direction in which it blurs. It's complement, 180° removed, blurs in the opposite direction. If you can tell the two apart, you have better eyesight than we do.
  2. Saturation controls streak width. That is, how much it looks like directional streaking and not omni-directional blurring.
    1. Saturation sets the eccentricity of the blurring ellipse, and full saturation corresponds to an eccentricity of one. The ellipses look like lines and the blur is a streak – all blurring goes in the color's direction, and none transverse to it.
    2. No saturation corresponds to an eccentricity of zero. The ellipses look like circles and the blur is uniformly diffuse in all directions. There is no discernible direction to the blur, left or right, up or down.
    3. All other values corresponds to some transverse blurring and some directional blurring.
  3. Lightness controls the amount of blurring.
    1. Light blurs a lot.
    2. Black blurs not at all.

    3. All other luminosities blur to some degree between black and white.

Workflow

  1. The blurring map goes into a separate layer, usually above or below the target layer, the one you are going to blur.
  2. Select your target layer, then select the Gimp-G'MIC plug-in from the Filters menu.
  3. When you bring up the Gimp-G'MIC plug-in, set the Input/Output control so that it can see the next layer above (or below) your target layer; which depends on whether you positioned your blurring layer immediately above or below your target layer.
  4. We strongly recommend setting the Output mode to create New Layer, so you can easily back out and start over.
  5. Turn off the preview until you are ready to use it. The Blur by Color filter is precise, good, but not fast! On this note, it is worth while to migrate your Gimp-G'MIC plug-in to at least version 1.5.9.3, better still 1.6.0.0, which has been available since mid August, 2014. Multi-core aware code is seeping throughout G'MIC and the -smooth command, upon which this filter is based, is a major benefactor of the refactoring.
  6. The Blur by Color filter lives under “Testing ->Gmic Tutorials->Blur by color.” If you don't see it, try the Refresh tool at the bottom of the Gimp-G'MIC dialog box. If it refuses to show up, question the usual gang of suspects.
  7. Preview bits and pieces of your project, then hit OK, or bail by Canceling.
  8. If, when previewing, you get a message in the preview window worded something like “Command 'local:' Invalid selection [-2,-1]…” followed by cryptic stuff, then the filter cannot find its blurring map. You need to set Input Layers, locate the blurring map next to your project layer, or maybe actually make the blurring map.

That's all you need to know. Go out and have fun.

You're Still Here

Perhaps the implications of these rules have yet to sink in. Like the handedness of the color wheel when you're trying to make a radial blur (it needs to be clockwise, red on top, blends through yellow to green on the right). How about blurring around a center, transverse to the radius?

Read on if you don't have the answer to that on the tip of your tongue. Or even if you do.

Basic Examples

1. Depth of Field

This is as simple as it gets. A monochrome ramp makes a graduated blur. No saturation, no direction – only magnitude. White blurs a lot, Black doesn't blur at all. You set the overall blurring scale from the filter's “amplitude” control. A common application for this kind of blur is fake depth of field.
The marbles lived in a layer above the monochrome ramp. The monochrome ramp was the next layer down. Our designated Input layer was “Active & Below”

2. Simple Directed Blur

With color comes directional blurring. Color and Saturation work hand-in-hand. The greater the saturation, the greater the preference in blurring in one particular orientation.

Color picks that orientation. In fact, each color and its complement always pick the same orientation. Lime green blurs from left to right, Blue violet blurs from right to left, at an orientation of 90° clockwise from 12 noon. Or is it the other way around (we forget)?

3. Colored Gradients

You don't have to work very hard to get some very interesting kinds of blurs. This is a graduated blur that we made from what was originally a horizontal black-to-white ramp which we modified through Gimp's Color → Curve tool. The red channel curve ramped down roughly along a quadratic curve, gray to black; blue ramped up along a similar curve; both hit zero at the midpoint. Green was constant 100%. The lime green color on the left hand edge of the map runs horizontally, cyan along the right hand edge runs vertically; the ramp made the change in orientation smooth and continuous.

4. Following Contours

It is also fairly trivial to blur around arbitrarily complex contours and shapes, as in this fake map of a shoreline.
One of the great things about Gimp-G'MIC filters is the help one gets from other Gimp-G'MIC filters. A big friend of Blur by Color is the Contours → Gradient RGB filter. Many folk use it for the rainbow effect it wraps around shapes, but cognoscenti know that these colors encode the direction of the steepest gradient in the locality of a pixel. Based on the same math, they tell Blur by Color how to blur around edges.
To make the blurring map on the right, we first used the Gimp-G'MIC filter Contours → Edges Offsets to calculate a radiating series of offset edges. That intermediary image was then used with Contours → Gradient RGB. We filtered the result through one step of Gimp's native Filters → Distorts → Value Propagate, and checked off the “More White” radio button to close one-pixel wide black slivers here and there. A gaussian blur gave us a cheap distance function to progressively desaturate the blurring map, softening the blur further from the “shoreline.”

5. Spirals

Color wheels get a section of their own because there seems to be no limit to their versatility. When composing a blurring map, usually by positioning it over the target layer and making it semi-opaque, one can proceed to position color wheels of various sizes and orientations to achieve various effects. One orientation garners radial blurs, another angular blurs and orientations in between produce spirals. If that isn't enough, counterclockwise spinning color wheels produce hyperbolic pairs.

6. Image based

The blurring map is an RGB Gradient filtering of a slightly Gaussian blurred street scene, with the colors of the blurring map rescaled to hues ranging from blue (240°) to red (360°), producing a kind of a windswept effect.

Figure 2: A clockwise color wheel with 0/360 degrees on top

Color Wheels

Color wheels were an unexpected boon to the writer, tipping him over the edge to write Yet Another Blurring Filter. Had he done the math he would have seen it coming, but he didn't and got surprised instead. Copy and paste color wheels into your blurring map where ever you want a radial/spiral/angular blur effect.

At two extremes color wheels will alternately generate radial blurs or angular blurs. These are, respectively the 0° and 90° orientation of the clockwise color wheel. Rotate the wheel counterclockwise at some other angle and get a counterclockwise spiral. Rotate the wheel clockwise for a clockwise spiral. Because you're composing a blurring map, you have a work flow advantage over using the dedicated radial and angular blurring filters. You can precisely position and orient as many color wheels as you want in strategic positions. You rotate color wheels not by the obvious choice, the Rotation tool, but by the Colors → Hue-Saturation tool, which doesn't actually move bits around. You isolate the color map to its own layer, the typical default case when you first load a color wheel from disk using Gimp's “File → Load as Layers” option.

You only need to make one. From then on, you will open it as a layer, resize it, flip it horizontally or vertically, desaturated the center or edges or points in between, twirl the colors around the wheel using Gimp's Colors → Hue-Saturation tool, select subset ranges with “Colors → Map →Rotate Colors...” dialog box, probably warping it as well. Stupid Cliché Time: “You are only limited by your imagination.” (Duh!)

Here we give two color wheel recipes, one based on the Gimp GUI and the other based on the G'MIC command line tool. Guess which one we prefer.

Make a Clockwise Color Wheel With Gimp

  1. Start Gimp. New Grayscale. Make it square and pretty big. 1000 pixels and up.
  2. Make the Hue channel.
    1. Set colors. Foreground color is white. Background color is black.
    2. Use the blend/gradient tool. Choose the Conical (asym.) style.
    3. Position the cursor on the middle pixel of the layer and mouse-down. Drag up to the top center edge. Hold down the control key with your free hand to keep the line vertical. Release when you are exactly on the top edge (whew!)
    4. You should see a white/left black/right transition line, straight up and down. The gradient should run from black to white in a clockwise direction.
      1. If it is the other way around (black/left, white/right), you probably forgot to set the foreground background colors. Go up to Colors→ Invert and invert.
      2. If the line isn't quite straight up or down, doesn't quite start in the center, doesn't quite reach or overshoots the edge, don't worry too much. We're kind of spastic too. See the end of this procedure.
  3. Make the Saturation Channel.
    1. New Layer. Fill it with white.
  4. Make the Luminance Channel.
    1. New layer. Fill it with middle gray (127 or 0x7F)
  5. Checkpoint: You should now have three layers. Let's pretend they're named Lum (the gray one), Sat (the white one) and Hue (the one that was a pain in the arse to make).
  6. Choose Colors→Components→Compose
    1. If that choice is not available (grayed out), maybe your program is in the wrong mode. You should be working with a gray scale image. Is Gimp in RGB? Indexed?
    2. In any case, do Image → Mode → Grayscale, then continue on.
  7. In the “Compose” dialog box, the “Compose Channels” section:
    1. Choose “HSL” for color model
  8. In the “Channel Representations” section:
    1. Set your “Hue” layer to occupy the Hue slot.
    2. Set your “Sat” layer to occupy the Saturation slot.
    3. Set your “Lum” layer to occupy the Lightness slot.
  9. Check. Double check. Fix what's wrong. Hit 'OK'.

For all that, you should have a clockwise color wheel. If it looks like the one starting this section, red on top, cyan on bottom, colors running clockwise from red to orange to yellow to green, you're in.

Do It In G'MIC

#@gmic #@gmic colorwheel : _size>0,_cclock={ 0 | 1 },_angle
#@gmic : Generates a square colorwheel in clockface orientation, with zero
#@gmic : degrees on top, corresponding to red, and colors transitioning
#@gmic : clockwise through green (120 degrees) and blue (240 degrees). size:
#@gmic : colorwheel edges, in pixels. cclock, boolean, if true generates a
#@gmic : counterclockwise colorwheel, and angle, degrees, rotates the wheel
#@gmic : clockwise (negative: counterclockwise) from its reference orientation.
#@gmic : Default values: _size=512, _cclock=0, _angle=0
colorwheel : -check ${1=512}>=1 -skip ${2=0},${3=0}
-e[^-1] "Input colorwheel $1 pixels square; cclockwise=$2; oriented $3 degrees"
-v -
$1,$1,1,1,'x=x-w/2;y=y-h/2;((1-2*!!$2)*(atan2(y,x)*180/pi+90-$3))%360'
100%,100%,1,2,1 -a[-2,-1] c -hsv2rgb[-1] -nm[-1] [colorwheel]
-v +

Since, after all, this is a web document about the G'MIC command language, we have to tell you how to do it in G'MIC. You get professional results without needing much hand dexterity.

If it is a decent amount of time after September 01, 2014, 5 PM UTC, (a day is more than enough) and you have an Internet connection, then typing:

gmic -update -colorwheel 1024 -o[-1] myclockwisecolorwheel.png

in a shell or some such will put 'myclockwisecolorwheel.png' in your local directory, a file containing a 1024 × 1024 pixel colorwheel.

That's it. You only have to use the -update command now and then, by the way. It goes out and fetches the latest G'MIC command definitions straight from the server at gmic.eu. You get the exact same results by pressing the Refresh button on the Gimp-G'MIC plugin top level dialog box; plugin or command line updates both.

If you only have partial connectivity or, for some reason your operating system doesn't have either one or another helper programs called 'curl' or 'wget' then copy and paste the sidebar contents into your ~/.gmic file (UNIX-like O/S) or /%APPDATA%/gmic (Windows).

Henceforth, then, just type '-colorwheel' and up to three arguments.

The first argument sets the size, in pixels, of the color wheel and is the only required one. The second argument sets whether the colors run clockwise (0, the default) or counterclockwise (1, you have to ask for it). The third, also optional, specifies a clockwise (positive) or counterclockwise (negative) twist which leaves red, normally twelve o'clock high, oriented at the offset angle you've specified.

We go into why these last two parameters might matter in the next section, a tutorial dedicated wholly to the color wheel.

Using Color Wheels

So you have a color wheel. Now what?

First off, just by itself, the color wheel is a quick reference guide to the Blur by Color filter. Red, straight up at 0° reminds you that it is the straight up and down blurring color. Cyan, 180° also blurs up and down. Lime Green and Violet are the horizontal blurring colors.

To get you started, the following constitutes a very basic variation on a theme. We start off with a blob of white salt-and-pepper noise on a black background. In most cases, we renormalized the result to the range of 0,255. The amplitude setting on the filter was, in all cases, maxed out at 1.00. The range was "N" (Normal) throughout.

The globular cluster. Airbrush tool with a 600 pixel brush set in Dissolve mode. Click. Click. Done. Call it the “Cluster” layer.

A clockwise color wheel. See the recipes in the previous section for how to make one.

This is a standard position for the color wheel. With red, at 0° straight up, there is 0° separation between its blurring direction and the ray connecting it to the center of the wheel. This is the case for all other colors: their blurring directions coincide with the angle of the ray connecting them to the center.

The next panel shows the effect of this particular alignment: the wheel-spoke pattern of radial blurring.

Filter → G'MIC and:

  1. Under Input/Output: select “Input layers...” and change it to “Active & Below”
  2. Also under Input/Output: select “Output mode...” and change it to “New Layer(s)”
  3. Select “Testing” → “Gmic Tutorials” → “Blur by color”
  4. The first time the Gimp-G'MIC filter starts, the preview check box is usually checked “on”, so the Blur by color will probably hem and haw for a little bit before displaying the star burst on the left. It will be darker than this.
  5. Hit “OK”. Should get what's on the left but darker, probably.
  6. Truth in Advertising; we re-normalized the image to 0-255 for this and following examples.

So. Yet Another Radial Blur. But Variations On A Theme always start off in old and familiar grooves. The big observation we want to make here is the effect that arises when a color's blurring direction coincides with the angle of the radial line connecting it to the center. Pixels smear right along the radius in a classic spoke-wheel pattern.

The next panel illustrates what happens when we rotate a color wheel so that colors reside at different points on the radius. It's a new game when red, with a blurring direction of zero degrees, connects to the center of the color wheel along the thirty degree radial line.  

Take the color wheel and rotate it about 30° clockwise: Color → Hue-Saturation, and pull the Hue slider ‒30° to rotate the color wheel clockwise. As an aside, the dialog box happens to regard positive rotations as counterclockwise, the right-handed rule. We spend so much time with bitmaps, where positive Y points down, that the left-handed rule prevails. It's positive rotations are clockwise.

Your color map should look like the one one the left, more or less, with the red region aimed at the northeast quadrant of the image.

Bring up the Gimp-G'MIC filter plug-in again and do what you did before, except for the setting-up exercises. You could probably just get by with a CTRL-F.

A spiral arises because a particularly bright (or dark) pixel diffuses only a very tiny amount before the parts of it diffusing upward fall under the purview of color rays slightly to the counterclockwise, while parts diffusing downward fall under the influence of color rays slightly to clockwise.

Consider a pixel under the purview of a pure red pixel in the blurring map. Red's blurring direction is zero degrees, so the pixel immediately start smearing straight up and down – but only for an infintesimal amount.

In this rotated color wheel, the set of red pixels in the blurring map now run along a ray of thirty degrees, so the top parts of the smeared pixel fall under the purview of slightly magenta pixels from the map, these with blurring angles infintesimally less than zero degrees. These still push that fraction of the smearing pixel mostly up, but also slightly to the left. The direction of diffusion changes just enough so that the pixel still smears across these slightly magenta rays at an incident angle of thirty degrees.

Correspondingly, the bits of the pixel smearing downward fall under the influence of slightly orange pixels from the map with blurring angles infintesimally greater than zero. These still push fractions fractions of the pixel mostly down, but also to the left. The direction of diffusion changes just enough so that the pixel still smears across these slightly orange pixels at an incident angle of thirty degrees.

Over the larger run, a wedge of color rays progressively diffuses the pixel up, to the left, and down to the left. As is the wont of the increasingly magenta (and later, blue) colors along radial lines less than thirty degrees, the smearing direction is progressively less upward and more leftward. And, as is the wont of the increasingly orange (and later yellow) colors along radial lines greater than thirty degrees, the smearing direction progressively less downward and more leftward.

In aggregate, the erstwhile pixel, initially a singular impulse on the thirty degree radial line of red pixels, is now diffusing along a path that intersects every color ray at a constant thirty degree incident angle, defining an arithmetic or Archemedian spiral.

As the incident angle increases, pixels diffuse along lines that progress at slower inward rates toward the center. Finally, When the incident reaches 90° pixels diffuse along paths that are always a constant direction from the center of the color wheel; they cannot spiral inward and follow circular paths instead. Angular blurring prevails.

We use the spiraling color map from the previous experiment and limit the rotation range through Gimp's Color → Map → Rotate Colors dialog box. We mapped the entire circle, 0° → 360° in the top section to the subset 0° → 180°, red to cyan.

It seems, from the color map, that we will have a terrible discontinuity, but recall that red and cyan are 180 apart in the color wheel and will blur along the same orientation.

Shock waves of a bullet passing through air? We'll keep this in mind when we need something like that.

Recalling the Hue rule and studying the orientation of the streaks, everything makes sense. Indeed, the direction of the blur are vertical in the cyan-red wedge, and angle to horizontal around lime green.

Thinking of our friend, Whirl-and-Pinch, induced us to Whirl-and-Pinch on a pristine clockwise color wheel.

Another spiral, but this of a different character, as the inward movement is not constant. This seems closer in spirit to the gravitational dynamics of spiral galaxies.

Everything we've played with up to now entail just the first rule – color sets direction. Here we desaturated the middle of the spiral

With desaturation, omni-directional diffusion prevails at the center of the spiral, which becomes featureless.

We mirror flip a pristine color wheel. The progression from red to orange to yellow, and so on, is now counter-clockwise.

Instead of a circle, we plot a pair of hyperbolae. The progression of colors is reversed and as we proceed around the circle in either a clockwise or counterclockwise direction, the progression of hues exhibit a change in blurring direction in the opposite sense, turning counterclockwise as we proceed clockwise.

A particularly bright (or dark) pixel will, unless exactly aligned with the vertical or horizontal axes, be swept along directions which turn away from, rather than turn upon, the center point; a hyperbolic trajectory results.

An Extended Example

Figure 3: Blurred by Color Crepuscular Rays Behind Diamond-Square Clouds

This walk through stems from 4. Following Contours a topic among the basic examples. That example is a particular case of harnessing the G'MIC filter Contours → Gradient RGB to translate geometry into blurring maps.

Gradient RGB's remit is to find edges (i.e. really, really steep gradients), and report their magnitude and orientation. For the latter, it uses a color coding scheme grounded on the HSL/HSV color wheel. That is, Gradient RGB uses red and cyan for vertically oriented edges, Lime Green and violet for horizontal edges and so forth. This is also how Blur by Color maps direction to color, so the marking done by Gradient RGB may, in principle, be harnessed by Blur by Color to produce a blurring map. The map mimics the edge orientations initially present in the drawing.

The plan, then, is to use some high contrast lines oriented in directions along which we'd like to blur, then run Gradient RGB to get a colorful blurring map that encodes these orientations. This becomes food for Blur by Color which will smear Diamond Cross clouds into crepuscular rays.

The faint crepusculars rays behind the Diamond-Square clouds begin life as a pair of Bèzier curves. They set the envelope of a family of curves which will ultimately shape the blurring map.

The rays themselves are nothing more than faint, semitransparent versions of the clouds. With a certain finesse, the variations among the rays can match those of the clouds – being more or less one and the same – and foster the illusion that the rays are shining through the clouds.

The curves set how the rays flare out from a center point and follow slightly curved tracks. This curving of rays has no basis in physical reality but it suits our fancy.

Inkscape's Path Effects Editor interpolates the inital paths into a graduated series of twenty five curves. There is nothing magical about twenty five. It could be ten or fifty. It should be enough to get a gradient without abrupt transitions, and no harm comes from overestimates.

To multiplex the pair of curves, we aggregate the initial pair into sub-paths of a single curve. Inkscape's “Path → Combine” menu operation does this for us.

This SVG image now becomes our template for the blurring map, which we create in Gimp using Gimp-G'MIC's “Contours → Gradient RGB” filter. We invoke “File → Save” using some memorable name, then depart Inkscape.

We open our work-in-progress illustration in Gimp.

With that partially built image in Gimp's current view, we then import the SVG file as a Layer, via “Files → Import as Layer”.

Gimp will put up a preview dialog box and furnish layer dimensions, based on the dot-per-inch ratio encoded within the SVG file. Inkscape's default of 90 dots-per-inch prevails unless told otherwise. You will probably want to adjust the proposed size of the layer to fit your project, then click on “OK” to complete the process.

Unless an SVG document background had been defined, the template lines will be black on a transparent background, convenient for positioning.

We generate the proto-blurring map with the Gimp-G'MIC plug-in

  1. Bring up the Gimp-G'MIC plug-in: Filters-->G'MIC

  2. Within the plug-in choose “Contours → Gradient RGB”

  3. Preview gives a trial rendering.

  4. Check the “Orientation Only” box

  5. Increase “Smoothness” until the black regions between the lines disappear.

  6. Hit “OK”

Upon seeing the stripes, one could easily jump to the conclusion that this prototype blurring map would blur images in two distinct directions.
Technically, that is correct, but the two directions share the same orientation, as they are 180° apart.
If you still find alternating colors unsettling, you may, optionally, use one of the custom command filters situated under the “Various” branch to write this snippet of G'MIC:
-remove_opacity
-rgb2hsl[-1]
-split[-1] c
-mod[-3] 180
-append[-3--1] c
-hsl2rgb

This snippet applies the modulus function to the data in the Hue channel so that values greater than 180° wrap around. Now, similarly oriented data share similar directions, making the blurring map easier to understand.
This is solely for our benefit, however. Blur by Color behaves the same with either style of map.

We desaturate and whiten a copy of the clouds layer, so they look like the fluffy stuff that inhabits mid day skies in the late spring or early summer of the Northern hemisphere.

The Blur by Color filter is grounded on the -smooth command and is very scale dependent. Since we intend to blur the clouds a lot, and likely beyond the maximum strength of the filter, we scale the layers of both the cloud artwork and the blurring map to one half of the image side.
With the artwork and map reduced in size, we:
  1. Make sure the clouds and the map occupy adjacent positions in Gimp's layer stack. Our habit is to stack the blurring map underneath the target layer that we are going to blur.
  2. Start the Gimp-G'MIC filter (“Filters → G'MIC”
  3. Under :Input/Output, select for Input layers: “Active & Below” (or Above, depending on the relative location of the map to the target layer)
  4. For Output mode: select “New layer(s)”
  5. Turn off Preview
  6. Set Range to “XM” – Maxed out!
  7. Set Amplitude to 1.0 – Maxed out
  8. Turn on Preview, and review. Adjust if needed then hit “OK”

We return the now-blurred, erstwhile cloud layer to the full size of the image and compare it against the Inkscape paths which initially set the direction.

Pre and Post

Before and after an insertion of crepuscular rays.

 Clouds and no rays.
Note how the rays wax in regions of fat clouds and thin out where clouds are thin, apropos of simply using the clouds themselves as a source of rays. We could have flipped the relationship by using a negative cloud image, have lots of rays where there are few clouds, or even more complex relationships. 

Blurring and Warping

A G'MIC volunteer who exhibits somewhat imperfect enthusiams… …is both warped and blown away by demonic tutorial editors, using the same underlying geometry to blur, warp and color the image.

A casual study of the Gimp-G'MIC Contour→GradientRGB reminds us that the manufacture of blurring maps for the Blur by Color filter has a close relationship to orientation and directional fields. Indeed, GradientRGB makes a rather routine Tinker to Evers to Chance play where -gradient characterizes intensity changes along an image's width and height, contained in two scalar fields (gray scale images). -append folds these into a 2D direction field, and -direction2rgb produces a color RGB representation of the same. This last element furnishes a blurring map based on the gradients found in the original image.

Of note is the intermediary product, the 2D direction field. Quite apart from being an intermediary in the production of a blurring map, it may  be harnessed by -warp to shift the geometry of an image. With the 2D direction field and the blurring map developed from it, one may then blur and warp an image in a coordinated way. Perhaps a stiff breeze can motion-blur a tree and bend it at the same time. Particulars follow; where we dissect the stiff breeze we used in our capacity as demonic tutorial editors.

Inkscape — Creating the Contour Lines

As in the Extended Example, we set up a template in Inkscape. These high contrast lines furnish detectable contours that sets the  blurring orientation. This particular set of lines describe the strong breeze manifest in the right hand panel, above.

Making the Prototype Blur Map — Gimp-G'MIC Filter: Contours → GradientRGB

  1. Smoothness: 1.5
  2. Min. Threshold: 0
  3. Max. Threshold: 100
  4. Checked "Orientation only"
  5. Preview Type: Full

Gainfully employed for making neon-light ribbons, Contours->Gradient RGB does have the technical remit to visualize, through color, the orientation and steepness of gradients.

To GradientRGB, most images look like assemblies of stretched, somewhat cut-up colorwheels and arcs of the same. For example, a horizontal line looks like a colorwheel rotated a quarter turn clockwise, stretched and snapped around the line. Blue violet dominates the top, lime green the bottom, and the remaining portions of the colorwheel are crowded to the ends.

As in the extended example, above, we're mainly interested in orientation, not degree of steepness, so we check the "orientation only" checkbox. With an emulation of an inconstant wind blast dominating our thinking, we do not smooth much either, leaving large black gaps representing calm eddies between fast-moving air streams. This is in contrast with the Extended Example. There were seeking a constant blurring field without intervening eddies and arranged our template geometry to lead to a solid mass of color.

Finishing the Blur Map — Gimp-GMIC Filter: Various  → Custom Code (global)

-if {s>3}
   -remove_opacity[-1]
-endif
-rgb2hsv[-1]
-split[-1] c
-mod[-3] 180
-append[-3--1] c
-hsv2rgb
-blur 10,1,0

This is the blurmap. We made use of the custom code filter to modify angular measure so that all blurring at a given orientation is specified by angles pointing in the same direction. That is the idea behind converting the image to the HSV color space and finding modulo 180° of the color angular measures; two colors that have the same blurring orientation are separated by exactly 180° and, after the modulo 180° operation, all colors with the same orientation will also have the same angular measure.

The Blur by color filter does not care about this issue, but our aim is to recreate/restore the 2D direction map allied with our blurring map. That recovery is simpler when we eliminate two angular measures for the same orientation.

We also blurred the blur map. This is to serve our artistic aims; we wished to have the streams of wind to have soft edges.

The Blur Applied — Testing → G'MIC Tutor Blur by Color

  1. Range: "N" (Normal)
  2. Amplitude: 30

This is the blurmap applied; the mainly lime green regions in the blurmap streak the art horizontally; variations between red and cyan give rise to an undulation.

Streaks alone do not offer all the hinting of strong wind; we shall warp the subect as well, but in a coordinated manner with blurring. To obtain that coordination, we convert the color blurring map into a two dimensional vector field, suitable for consumption by -warp.

Computing the Vector Field — Gimp-GMIC Filter: Various  → Custom Code (global)

-if {s>3}
 -remove_opacity[-1]
-endif
-rgb2hsv[-1]
-split[-1] c # H[0],S[1],V[2]
-reverse[0,-1]
-rm[-2]
-fill[-1] 2*pi*(((i-90)%360)/360)
--cos[-1]
-sin[-2]
-mul[-2] [-3]
-mul[-1,-3]
-append[-2,-1] c
-mul[-1] 60

The custom G'MIC code finds a directional vector field which warps in directions similar to the orientations of the colors in the blurring map.

A ninety degree counterclockwise rotation converts from one to the other. In particular, we move to the HSV colorspace to obtain measures of Hue in angular degree notation. We rotate these measures -90°, convert to radian measure, then convert the Hue field into horizontal and vertical vector components by way of the cosine and sine trigonometric functions. Out of the box, these are components of unit vectors, expressing only orientation. We introduce wind strength by multiplying these vector components by the Value field.

The idea of saturation does not carry over into the 2D direction field, so we simply delete it.

We scale the directional vector field by 60, a heuristic which we determined experimentally. 

The Warp Applied — Gimp-GMIC Filter: Various  → Custom Code (global)

-warp[-2] [-1],1

It is the nature of the 2D directional field to warp strongly toward the right just in the areas where the "wind" (blur) is strongest, but not warp much at all where the wind is weak. The direction of warping is also coincident with the direction of blurring, as desired.

What is missing, however, is a visual cue of where the wind is strongest. We utilize the original Inkscape template, this time as a blending color for slightly opaque air.

Rendering Atmospherics — File → Open As Layers

  • template.svg (or whatever you have named the initial Structured Vector Graphics file used in the first panel)
  • Render Scaleable Vector Graphics: Accept defaults (should be your image size)

Rendering Atmospherics — Color → Colorize:

  • Hue: 200
  • Saturation:: 60
  • Value: 80

Rendering Atmospherics — Filter → Blur → Gaussian Blur:

  • Horizontal: 40
  • Vertical: 40
  • Blur Method: RLE (Run length encoding)

Rendering Atmospherics — Colors → Curves

  • Channel: Alpha — Map x:32 to y: 255 (A steep, almost vertical slope)
  • Curve Type: Smooth
  • Preview: Checked

Rendering Atmospherics — Layers → Merge Down

Adding a slight atmospheric opacity is standard Gimp fare - we can't imagine having to explain that in detail to the gentle readers out there, who could probably pick a better way, and certainly a different way. The parameters we used above stem primarily from our sense of taste - or tastelessness, as the case may be - and can be varied for different effects.

Postscript

We could go on and on, there is no end in sight, but we have to call it a day somewhere. We'll close shop with a gallery of odds and ends, tips and techniques, more or less centered on Blur by color, as they strike our fancy. Go out and play now, but stop by from time to time to see what might be added.

Rain. Salt & pepper noise and a a blurring map that is a solid, reddish color. Not exactly red. Not fully saturated. Iterate two or three times with pristine S&P noise and the red hue of the blurring map shifted five or ten degrees this way and that on each loop, so that you get two or three courses of rain, just off vertical, criss-crossing. Range: "N" (normal) Amplitude: 0.25-0.45. Compose over a noir-ish image with "Lighten Only." For particular drear, as was done here, take one of the rain courses and make it the blurring map, colorizing it reddish, perhaps using the old blurring map, so that you have red streaks on a dark background. Use that to blur the noir-ish image. It makes streaks of blur that seem to catch the light from street lamps, as real rain would when falling past these illuminants. 

This arises from a two-pass workflow, based the basic example  6. Image based. We turned Gradient RGB loose on a slightly blurred original, (10 pixel radius), making an "Orientation Only" edge detection image. We used Colors → Map → Rotate Colors to map the full rotation range into the subset running from 60 to -300 degrees – generally vertical blurring but with many side-to-side sweeps. That, in essence, is the workflow of the basic example.

Then we looped again, turning Gradient RGB loose on the already blurred results. This time, however, we left "Orientation Only" unchecked for complete edge detection and stretched the contrast of the resulting map from 0 to 255. We remapped its colors from the full rotation range into the subset running from 60 to -300 degrees, as before. As before, we obtained generally vertical blurring with side-to-side sweeps, but now the blurring map had many dark places where edges were not particularly strong in the intermediary image. We turned this second-generation blurring map loose on a pristine copy of the original photograph. We find the selective blurring enchanting and somewhat mysterious. Vast areas are unchanged, but a single dead branch induces a sudden fury of directional blurring.

The following credit contains a link to the original image, and clicking on the image above will bring up a larger version.

Dead tree, Breadalbane, New South Wales. Image by CephasOz, Wikimedia Commons

 

Franklin Wesson House, Worcester, MA, United States —  Namiba, Wikimedia Commons

 A short while ago, I was looking at early twentieth century photographs taken by a Kodak Brownie Model 2A which had a single element meniscus lens that made photographs that were pretty sharp in the middle but progressively less focussed toward the corners. At $3.00 (1907, effectively $70 USD now), it made photography accessible to the middle class and so the snapshot was born. Two G'MIC-Gimp filters emulate this old camera. Tom Keil's "Vintage Style" filter, in the "Colors" branch, puts a contemporary image of the Wesson House into a kind of a photographic wayback machine, recoloring as if it was a century old sepia print — or a print that had turned sepia with age. The blurring map I used to emulate the center-to-edge drop-off in focus was a colorwheel multiplied with a black-to-white radial ramp. To pull it off fully, I had to desaturate the colorwheel by 30-40 so that there would be some transverse blurring as well as radially oriented blurring.  The blur-by-color global settings were Range: VL and Amplitude 21. The "Vintage Style" settings were left at default except for two: Saturation was set to zero, and Strength midtone was set to 0.66. The 1870-vintage Victorian Gothic style of the Frank Wesson House certainly helps; applying these effects to a big box store in a twentifirst century mall just wouldn't seem the same.