The blur command (abbreviated: -b) replaces every pixel in an image with a weighted average that includes the pixel itself (the center pixel, having the greatest weight) and neigboring pixels, each weighted in a way that become progressively weaker the further a neighboring pixel is from the center pixel. In the Gaussian form of this command, a Gaussian distribution determines rate of drop-off of the weights. The std_variation parameter of this command controls the extent of the distribution and, indirectly, the rate of drop-off.
The blur command is implemented through a convolution, the kernel being either a Gaussian distribution or a less computationally intensive approximation. This command shares quite a bit of basic machinery with the -convolve command and much of the inner workings of the blur command may be found there.
Informally, the blur command smears images, replacing abrupt transitions in color or intensity with more gradual transitions. Artists frequently employ the blur command to soften noise, usually at the expense of sharp edges. In many cases, the -smooth command is the better noise management tool, as it preserves edges, though it is a computationally expensive tool and its effective use sometimes depends on a subtle use of its parameters. In contrast, blur is a fast tool and easy to use; it may very well serve the purposes at hand.
The format of the command is:
-blur:
Blur selected images by a quasi-gaussian or gaussian filter (recursive implementation)
std_variation>=0[%],_boundary,_kernel
axes,std_variation>=0[%],_boundary,_kernel
std_variation sets the spread of the Gaussian distribution kernel, indirectly its effective size and informally the amount of blurring. Small numbers, 5 or less, effectively soften pixel size noise; the main features of the image remain intact. Larger numbers substantially change the image and very large numbers replace an image with its average color. One must supply this value; there is no default.
_boundary chooses a policy about how to handle image edges; see "Pictures have Edges. Now What?" for technical details. a zero flag (0, Dirichlet) assumes that off-image pixels are black. For fairly large values of standard variation, this policy gives rise to a black vignette, which may be pleasing or infuriating, depending on one's purposes and frame of mind. A unit flag (1, Neumann) assumes that off-image pixels have the exact same value as the nearest edge pixel. This eliminates the vignette, but sometimes edge values become uncommonly bright. Neither policy is better than the other, and neither offer a general solution to the "edge problem," but in particular cases, one offers a better result than the other. This value may be omitted and when it is, the command uses the Neumann policy as a default.
_kernel chooses an approximate "quasi-gaussian" kernel when set to zero, or a true Gaussian kernel when set to one. The quasi-gaussian flag also allows use of a somewhat simplified convolution procedure that is faster, but not exactly adhering to definition. It is very difficult to tell the difference in results, and the faster choice can make a difference when processing large image stacks. The Gaussian kernel may be the better choice if further processing of the image is contemplated; downstream commands may reveal noise that the quasi-gaussian variant leaves behind. This value may be omitted; the quasi-gaussian kernel is the default.
axes restricts blurring along (combinations of) x, y, and z axes. One can restrict blurring to just x, y, or z by writing one or another letter in isolation. One may also blur along combinations of axes by choosing two distinct letters. One may harmlessly specify 'xyz' and obtain the same result as not using the axes argument at all. For asymmetric blurring, one may specify a particular axis multiple times. So, to triple-blur along the x axis, but have no blurring at all along the z axis, one could write …-blur xxxy,4… which will apply a blur with standard deviation of 4 along the y axis, but 12 along the x axis and 0 along the z axis.
Application
The blur command has a general implementation that functions with images possessing depth — that is, images that represent three dimensional solids or images that record two dimensional surfaces that change with time. To G'MIC, the distinction is largely immaterial. When operating on images with more than one slice, the blur command operates over a spherical neighborhood instead of a circular one. As a practical manner, this can be a source of quickly composed animation effects; the clip on the left illustrates the concept. The command that made this video is very straightforward:
First, we conjure from the aether a contiguous volume 360 pixels wide, 240 pixels high and three hundred slices deep, sufficient for a ten second video clip at a rate of thirty frames per second. (gmic 360,240,300,3... )
We salt-and-pepper this initially solid black volume with a fairly sparse pattern of pixels (...-noise[-1] 0.02,2... ). Since we conjured up three channel slices, these pixels will be red, green or blue, a tedious color combination, but sufficient for demonstration purposes. If you scrub through the image volume at this point in the pipeline (insert -display after -noise), the animation would have the appearance of dirty film, with red, green and blue spots flashing hither and yon in space and time.
(...-blur[-1] 6,0,1...) is the heart of the matter; it smears these single pixel flashes across height, width and depth, making blur-balls. This clip stems from a standard variation of six, making blobs about a dozen pixels around in space and time. One could see these pixels wax, pass through maximum intensity and wane in about half a second. Using larger a standard variation value slows the pace of variation; the enlarged blobs mixing into one another, giving rise to pastels. We used the Dirichlet flag for black vignetting around the edges, but it also gave us a free fade-in and fade-to-black. We happened to use a genuine Gaussian kernel but the quasi version works just as well.
The last three commands constitute housekeeping. By nature, -noise generates intensity one signals; we normalize the image to the range 0,255 for eight bit color (...-normalize[-1] 0,255...). Notice that the right hand decoration references only one image on the stack; that image has, we recall, a depth of 300 slices, but is still only one image in G'MIC terms. In preparation for output, we split our single, three hundred slice image along the depth axis (z) into three hundred single slice images, necessary for the -output command (-split[-1] z). We do not decorate the -output command with an image selection. This induces the output command to send the entire image stack to the output file. The -output command recognizes the 'avi' extension as a video container format, in this case the Audio Video Interleaved format common to Microsoft Windows platforms.
A Large Bag of Blurs
The axes command argument subsumes -blur_xyz, -blur_xy, -blur_x, -blur_y, and -blur_z commands, each which also allow the standard variation to be independently set along combination of axes. These older commands are being retained for backward compatibility.