# Image Effects

You have your choice of these special effects:

  channel F(x)
    exchange, extract, or copy one or more image channels.

    The expression consists of one or more channels, either mnemonic or numeric (e.g. red, 1), separated by certain operation symbols as follows:

          <=>     exchange two channels (e.g. red<=>blue)
          =>      copy one channel to another channel (e.g. red=>green)
          =       assign a constant value to a channel (e.g. red=50%)
          ,       write new image with channels in the specified order (e.g. red, green)
          |       replace the specified channel in the first image with the specified
                  channel in the second image (e.g. red | green)
          ;       separate each specified channel to its own image (e.g. red; green;
                  blue)

    For example, to create 3 grayscale images from the red, green, and blue channels of an image, use:

          -channel-fx "red; green; blue"

    A channel without an operation symbol implies separate (i.e, semicolon).

          red; green; blue

  Charcoal drawing
    simulate a charcoal drawing. Good parameter values are odd numbers from 3 to 31
  Clut
    apply the clipboard image as a color lookup table to the image.
  Color-matrix
    This option permits saturation changes, hue rotation, luminance to alpha, and various other effects. Although variable-sized transformation matrices can be used, typically one uses a 5x5 matrix for an RGBA image and a 6x6 for CMYKA (or RGBA with offsets). The matrix is similar to those used by Adobe Flash except offsets are in column 6 rather than 5 (in support of CMYKA images) and offsets are normalized (divide Flash offset by 255). As an example, to add contrast to an image with offsets, try this

          1.5 0.0 0.0 0.0, 0.0, -0.157 0.0 1.5 0.0 0.0, 0.0, -0.157 0.0 0.0 1.5 0.0, 0.0, -0.157 0.0 0.0 0.0 1.0, 0.0,  0.0 0.0 0.0 0.0 0.0, 1.0,  0.0 0.0 0.0 0.0 0.0, 0.0,  1.0

  Convolve
    apply a convolution kernel to the image. Given the kernel order, you would supply order*order float values. For example, the parameter would look like this for a 3x3 Gaussian kernel:

            1, 2, 1, 2, 4, 2, 1, 2, 1

  Distort
    distort an image with as defined by a source and destination quadrilateral.
    The parameter is a set of coordinate pairs (e.g. x1,y1,u1,v1 x2,y2,u2,v2 ...).
  Evaluate
    evaluate an arithmetic, relational, or logical expression.
    The parameter is a value to evaluate against each pixel.
  Function
    apply function to image.
    The parameter is a set of coordinate pairs (e.g. x1,y1,u1,v1 x2,y2,u2,v2 ...).
  Fx
    evaluate expression for each pixel in the specified channel. The Fx expressions includes any combination of the following:
    - x `^` y: exponentiation (xy)
    - `(` ... `)`: grouping
    - x `*` y: multiplication (the asterisk `*` is optional, for example, `2u` or `2(x+y)` are acceptable)
    - x `/` y: division
    - x `%` y: modulo
    - x `+` y: addition
    - x `-` y: subtraction
    - x `<<` y: left shift
    - x `>>` y: right shift
    - x `<` y: boolean relation, returns value 1.0 if x < y, otherwise 0.0
    - x `<=` y: boolean relation, returns value 1.0 if x <= y, otherwise 0.0
    - x `>` y: boolean relation, returns value 1.0 if x > y, otherwise 0.0
    - x `>=` y: boolean relation, returns value 1.0 if x >= y, otherwise 0.0
    - x `==` y: boolean relation, returns value 1.0 if x == y, otherwise 0.0
    - x `!=` y: boolean relation, returns value 1.0 if x != y, otherwise 0.0
    - x `&` y: binary AND
    - x `|` y: binary OR
    - x `&&` y: logical AND connective, returns value 1.0 if x > 0 and y > 0, otherwise 0.0
    - x `||` y: logical OR connective (inclusive), returns value 1.0 if x > 0 or y > 0 (or both), otherwise 0.0
    - `~`x: logical NOT operator, returns value 1.0 if not x > 0, otherwise 0.0
    - `+`x: unary plus, returns 1.0*value
    - `-`x: unary minus, returns -1.0*value
    - x `?` y : z: ternary conditional expression, returns value y if x > 0, otherwise z; only one ternary conditional permitted per statement
    - x `=` y: assignment
    - x `;` y: statement separator
    - `pi`: constant (3.141659...)
    - `e`: constant (2.71828...)
    - `QuantumRange`: constant maximum pixel value (255 for Q8, 65535 for Q16)
    - `QuantumScale`: constant 1.0/`QuantumRange`
    - `intensity`: pixel intensity
    - `hue`: pixel hue
    - `saturation`: pixel saturation
    - `luminosity`: pixel luminosity
    - `red, green, blue`, etc.: color names
    - `#ccc, #cbfed0, #b9e1cc00`, etc.: color hex values
    - `rgb(), rgba(), cmyk(), cmyka(), hsl(), hsla()`: color functions
    - `s,t,u,v,n,i,j,w,h,z,r,g,b,a,o,c,y,m,k`: symbols
    - `abs(`x`)`: absolute value function
    - `acos(`x`)`: arc cosine function
    - `alt(`x`)`: sign alternation function (returns 1 if `int(`x`)` is even, -1 if `int(`x`)` is odd)
    - `asin(`x`)`: arc sine function
    - `atan(`x`)`: arc tangent function
    - `atan2(`y,x`)`: arc tangent function of two variables
    - `ceil(`x`)`: smallest integral value not less than argument
    - `cos(`x`)`: cosine function
    - `debug(`x`)`: print value for debugging
    - `exp(`x`)`: natural exponential function (ex)
    - `floor(`x`)`: largest integral value not greater than argument
    - `int(`x`)`: greatest integer function (returns greatest integer less than or equal to x)
    - `ln(`x`)`: natural logarithm function
    - `log(`x`)`: logarithm base 10
    - `max(`x, y`)`: maximum of x and y
    - `min(`x, y`)`: minimum of x and y
    - `mod(`x, y`)`: floating-point remainder function
    - `pow(`x,y`)`: power function (xy)
    - `rand()`: value uniformly distributed over the interval [0.0, 1.0) with a 2 to the 128th-1 period
    - `sign(`x`)`: returns 1 if x is less than 0 otherwise 1
    - `sin(`x`)`: sine function
    - `sqrt(`x`)`: square root function
    - `tan(`x`)`: tangent function
    The expression semantics include these rules:
    - symbols are case insensitive
    - only one ternary conditional (e.g. x ? y : z) per statement
    - statements are assignments or the final expression to return
    - an assignment starts a statement, it is not an operator
    - assignments to built-ins do not throw errors and have no effect; e.g. `r=3.0; r` returns the pixel red color value, not 3.0
  Hald-Clut
    apply the clipboard image as a Hald color lookup table to the image.
  Implode
    implode/explode image pixels about the center. A positive parameter implodes while a negative parameter explodes the image.
  mosaic
    create an mosaic from an image sequence.
  Morph
    morphs an image sequence. Both the image pixels and size are linearly interpolated to give the appearance of a meta-morphosis from one image to the next. Specify the parameter as the number of in-between images to generate. If you have a single image in your sequence, the clipboard image is used as the morph anchor.
  Oil Paint
    simulate an oil painting. Each pixel is replaced by the most frequent color in a circular neighborhood whose width is specified as a radius. Good parameter values are odd numbers from 3 to 31
  Sepia Tone
    apply a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning. Threshold ranges from 0 to MaxRGB and is a measure of the extent of the sepia toning. A threshold of 80% is a good starting point for a reasonable tone.
  Shadow
    simulate an image shadow. Start with a parameter of 50x5+20+30. The first value is the percent opacity, the second is the blur sigma value, and the third and fourth value is the shadow offset relative to the original image
  Sketch
    simulate a pencil sketch. Try a parameter of 0x20+135.
  Solarize
    negate all pixels above the threshold level. Specify the parameter as the percent threshold of the intensity (0 - 99.9%).
  Sparse-Color
    given a set of coordinates, sparse-color interpolates the colors found at those coordinates, across the whole image, using various methods.
  Stegano
    hide the clipboard image within this image. The parameter is the offset within the image to begin any hiding.
  Stereo
    combine two image to create a stereo anaglyph. The left side of the stereo pair is saved as the red channel of the output image. The right sife is saved as the green channel. Red-blue stereo glasses are required to properly view the stereo image.
  Swirl
    swirl image pixels about the center. Degrees defines the tightness of the swirl.
  Tint
    tint the image with the fill color. Tint applies a color vector to each pixel in the image. The length of the vector is 0 for black and white and at its maximum for the midtones. The vector weighting function in between is f(x) = (1-(4.0*((x-0.5)*(x-0.5)))). The dynamic weighting can be controlled by a constant percentage (0..100) given as the parameter for tint (e.g. 50%). Usually de-saturating the image is what you want before tinting.
  Vignette
    soften the edges of the image in vignette style. Start with a parameter of 0x20. The first value is the blur radius, the second is the blur sigma value, and the third and fourth value is the vignette offset relative to the original image
  Wave
    alter an image along a sine wave. Specify amplitude and wavelength as the parameter to effect the characteristics of the wave:

            <amplitude>x<wavelength>

See examples of select ImageMagick Studio effects.