GraphicsMagick

- Home
- Project
- Download
- Install
- Source
- News
- Utilities
- Programming
- Reference

# effect

## Image effects methods

Contents

- AdaptiveThresholdImage
- AddNoiseImage
- AddNoiseImageChannel
- BlackThresholdImage
- BlurImage
- BlurImageChannel
- ChannelThresholdImage
- ConvolveImage
- DespeckleImage
- EdgeImage
- EmbossImage
- EnhanceImage
- GaussianBlurImage
- GaussianBlurImageChannel
- MedianFilterImage
- MotionBlurImage
- RandomChannelThresholdImage
- ReduceNoiseImage
- ShadeImage
- SharpenImage
- SharpenImageChannel
- SpreadImage
- ThresholdImage
- UnsharpMaskImage
- UnsharpMaskImageChannel
- WhiteThresholdImage

# AdaptiveThresholdImage

## Synopsis

    Image *AdaptiveThresholdImage( Image *image, const unsigned long width,
                                   const unsigned long height, const unsigned long unsigned long,
                                   ExceptionInfo *exception );

## Description

AdaptiveThresholdImage() selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood. This allows for thresholding of an image whose global intensity histogram doesn't contain distinctive peaks.

The format of the AdaptiveThresholdImage method is:

    Image *AdaptiveThresholdImage( Image *image, const unsigned long width,
                                   const unsigned long height, const unsigned long unsigned long,
                                   ExceptionInfo *exception );

image:
  The image.
width:
  The width of the local neighborhood.
height:
  The height of the local neighborhood.
offset:
  The mean offset.
exception:
  Return any errors or warnings in this structure.

# AddNoiseImage

## Synopsis

    Image *AddNoiseImage( const Image *image, const NoiseType noise_type,
                          ExceptionInfo *exception );

## Description

AddNoiseImage() adds random noise to the image.

The format of the AddNoiseImage method is:

    Image *AddNoiseImage( const Image *image, const NoiseType noise_type,
                          ExceptionInfo *exception );

image:
  The image.
noise_type:
  The type of noise: Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson, or Random.
exception:
  Return any errors or warnings in this structure.

# AddNoiseImageChannel

## Synopsis

    Image *AddNoiseImageChannel( const Image *image, const ChannelType channel,
                                 const NoiseType noise_type, ExceptionInfo *exception );

## Description

AddNoiseImageChannel() adds random noise to one image channel.

The format of the AddNoiseImageChannel method is:

    Image *AddNoiseImageChannel( const Image *image, const ChannelType channel,
                                 const NoiseType noise_type, ExceptionInfo *exception );

image:
  The image.
channel:
  The image channel to apply noise to.
noise_type:
  The type of noise: Uniform, Gaussian, Multiplicative, Impulse, Laplacian, Poisson, or Random.
exception:
  Return any errors or warnings in this structure.

# BlackThresholdImage

## Synopsis

    MagickPassFail BlackThresholdImage( Image *image, const char *thresholds );

## Description

BlackThresholdImage() adjusts the levels of image channels such that values below a specified threshold are set to the minimum value (black) while the remaining pixels are unchanged.

The format of the BlackThresholdImage method is:

    MagickPassFail BlackThresholdImage( Image *image, const char *thresholds );

A description of each parameter follows:

image:
  The image.
thresholds:
  Channel thresholds which are specified as a comma delimited list containing the thresholds for red, green, blue, and opacity. If the list contains a percent symbol (%) then all values are treated as a percentage of MaxRGB.

# BlurImage

## Synopsis

    Image *BlurImage( const Image *image, const double radius, const double sigma,
                      ExceptionInfo *exception );

## Description

BlurImage() blurs an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and BlurImage() selects a suitable radius for you.

The format of the BlurImage method is:

    Image *BlurImage( const Image *image, const double radius, const double sigma,
                      ExceptionInfo *exception );

radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Gaussian, in pixels.
exception:
  Return any errors or warnings in this structure.

# BlurImageChannel

## Synopsis

    Image *BlurImageChannel( const Image *image, const ChannelType channel,
                             const double radius, const double sigma,
                             ExceptionInfo *exception );

## Description

BlurImageChannel() blurs the specified image channel. We convolve the image channel with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and BlurImageChannel() selects a suitable radius for you.

The format of the BlurImageChannel method is:

    Image *BlurImageChannel( const Image *image, const ChannelType channel,
                             const double radius, const double sigma,
                             ExceptionInfo *exception );

channel:
  The channel to blur.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Gaussian, in pixels.
exception:
  Return any errors or warnings in this structure.

# ChannelThresholdImage

## Synopsis

    MagickPassFail ChannelThresholdImage( Image *image, const char *threshold );

## Description

ChannelThresholdImage() changes the value of individual pixels based on the level of each pixel channel. The result sets the affected channels to the minimum or maximum channel value. A negative threshold value disables thresholding for that channel. Append a percent symbol to have threshold values automatically scaled from a percentage to MaxRGB.

Invoked by the '-threshold' option.

The format of the ChannelThresholdImage method is:

    MagickPassFail ChannelThresholdImage( Image *image, const char *threshold );

A description of each parameter follows:

image:
  The image.
threshold:
  define the threshold values, <red>{<green>,<blue>,<opacity>}{%}.

# ConvolveImage

## Synopsis

    Image *ConvolveImage( const Image *image, const unsigned int order,
                          const double *kernel, ExceptionInfo *exception );

## Description

ConvolveImage() applies a custom convolution kernel to the image.

The format of the ConvolveImage method is:

    Image *ConvolveImage( const Image *image, const unsigned int order,
                          const double *kernel, ExceptionInfo *exception );

image:
  The image.
order:
  The number of columns and rows in the filter kernel.
kernel:
  An array of double representing the convolution kernel.
exception:
  Return any errors or warnings in this structure.

# DespeckleImage

## Synopsis

    Image *DespeckleImage( const Image *image, ExceptionInfo *exception );

## Description

Despeckle() reduces the speckle noise in an image while preserving the edges of the original image.

The format of the DespeckleImage method is:

    Image *DespeckleImage( const Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:
  The image.
exception:
  Return any errors or warnings in this structure.

# EdgeImage

## Synopsis

    Image *EdgeImage( const Image *image, const double radius,
                      ExceptionInfo *exception );

## Description

EdgeImage() finds edges in an image. Radius defines the radius of the convolution filter. Use a radius of 0 and Edge() selects a suitable radius for you.

The format of the EdgeImage method is:

    Image *EdgeImage( const Image *image, const double radius,
                      ExceptionInfo *exception );

image:
  The image.
radius:
  the radius of the pixel neighborhood.
exception:
  Return any errors or warnings in this structure.

# EmbossImage

## Synopsis

    Image *EmbossImage( const Image *image, const double radius, const double sigma,
                        ExceptionInfo *exception );

## Description

EmbossImage() returns a grayscale image with a three-dimensional effect. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and Emboss() selects a suitable radius for you.

The format of the EmbossImage method is:

    Image *EmbossImage( const Image *image, const double radius, const double sigma,
                        ExceptionInfo *exception );

image:
  The image.
radius:
  the radius of the pixel neighborhood.
sigma:
  The standard deviation of the Gaussian, in pixels.
exception:
  Return any errors or warnings in this structure.

# EnhanceImage

## Synopsis

    Image *EnhanceImage( const Image *image, ExceptionInfo *exception );

## Description

EnhanceImage() applies a digital filter to the image color channels that improves the quality of a noisy image. The opacity channel is preserved but is otherwise ignored.

The format of the EnhanceImage method is:

    Image *EnhanceImage( const Image *image, ExceptionInfo *exception );

A description of each parameter follows:

image:
  The image.
exception:
  Return any errors or warnings in this structure.

# GaussianBlurImage

## Synopsis

    Image *GaussianBlurImage( const Image *image, const double radius, const double sigma,
                              ExceptionInfo *exception );

## Description

GaussianBlurImage() blurs an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and GaussianBlurImage() selects a suitable radius for you

The format of the GaussianBlurImage method is:

    Image *GaussianBlurImage( const Image *image, const double radius, const double sigma,
                              ExceptionInfo *exception );

blur_image:
  Method GaussianBlurImage returns a pointer to the image after it is blur. A null image is returned if there is a memory shortage.
image:
  Image to blur.
radius:
  the radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  the standard deviation of the Gaussian, in pixels.
exception:
  Return any errors or warnings in this structure.

# GaussianBlurImageChannel

## Synopsis

    Image *GaussianBlurImageChannel( const Image *image, const ChannelType channel,
                                     const double radius, const double sigma,
                                     ExceptionInfo *exception );

## Description

GaussianBlurImageChannel() blurs an image channel. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, the radius should be larger than sigma. Use a radius of 0 and GaussianBlurImage() selects a suitable radius for you.

The format of the GaussianBlurImageChannel method is:

    Image *GaussianBlurImageChannel( const Image *image, const ChannelType channel,
                                     const double radius, const double sigma,
                                     ExceptionInfo *exception );

blur_image:
  Method GaussianBlurImage returns a pointer to the image after it is blur. A null image is returned if there is a memory shortage.
image:
  Image to blur.
channel:
  Channel to blur in image.
radius:
  the radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  the standard deviation of the Gaussian, in pixels.
exception:
  Return any errors or warnings in this structure.

# MedianFilterImage

## Synopsis

    Image *MedianFilterImage( const Image *image, const double radius,
                              ExceptionInfo *exception );

## Description

MedianFilterImage() applies a digital filter that improves the quality of a noisy image. Each pixel is replaced by the median in a set of neighboring pixels as defined by radius.

The algorithm was contributed by Mike Edmonds and implements an insertion sort for selecting median color-channel values. For more on this algorithm see "Skip Lists: A probabilistic Alternative to Balanced Trees" by William Pugh in the June 1990 of Communications of the ACM.

The format of the MedianFilterImage method is:

    Image *MedianFilterImage( const Image *image, const double radius,
                              ExceptionInfo *exception );

image:
  The image.
radius:
  The radius of the pixel neighborhood.
exception:
  Return any errors or warnings in this structure.

# MotionBlurImage

## Synopsis

    Image *MotionBlurImage( const Image *image, const double radius, const double sigma,
                            const double angle, ExceptionInfo *exception );

## Description

MotionBlurImage() simulates motion blur. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and MotionBlurImage() selects a suitable radius for you. Angle gives the angle of the blurring motion (direction object appears to be coming from).

Andrew Protano contributed this effect.

The format of the MotionBlurImage method is:

    Image *MotionBlurImage( const Image *image, const double radius, const double sigma,
                            const double angle, ExceptionInfo *exception );

image:
  The image.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Gaussian, in pixels.
angle:
  Apply the effect along this angle.
exception:
  Return any errors or warnings in this structure.

# RandomChannelThresholdImage

## Synopsis

    unsigned int RandomChannelThresholdImage( Image *image, const char *channel,
                                              const char *thresholds,
                                              ExceptionInfo *exception );

## Description

RandomChannelThresholdImage() changes the value of individual pixels based on the intensity of each pixel compared to a random threshold. The result is a low-contrast, two color image.

The format of the RandomChannelThresholdImage method is:

    unsigned int RandomChannelThresholdImage( Image *image, const char *channel,
                                              const char *thresholds,
                                              ExceptionInfo *exception );

image:
  The image.
channel:
  The channel or channels to be thresholded.
thresholds:
  a geometry string containing LOWxHIGH thresholds. If the string contains 2x2, 3x3, 4x4, 5x5, 6x6, or 7x7, then an ordered dither of order 2, 3, 4, 5, 6, or 7 will be performed instead.
exception:
  Return any errors or warnings in this structure.

# ReduceNoiseImage

## Synopsis

    Image *ReduceNoiseImage( const Image *image, const double radius,
                             ExceptionInfo *exception );

## Description

ReduceNoiseImage() smooths the contours of an image while still preserving edge information. The algorithm works by replacing each pixel with its neighbor closest in value. A neighbor is defined by radius. Use a radius of 0 and ReduceNoise() selects a suitable radius for you.

The format of the ReduceNoiseImage method is:

    Image *ReduceNoiseImage( const Image *image, const double radius,
                             ExceptionInfo *exception );

image:
  The image.
radius:
  The radius of the pixel neighborhood.
exception:
  Return any errors or warnings in this structure.

# ShadeImage

## Synopsis

    Image *ShadeImage( const Image *image, const unsigned int gray, double azimuth,
                       double elevation, ExceptionInfo *exception );

## Description

ShadeImage() shines a distant light on an image to create a three-dimensional effect. You control the positioning of the light with azimuth and elevation; azimuth is measured in degrees off the x axis and elevation is measured in pixels above the Z axis.

The format of the ShadeImage method is:

    Image *ShadeImage( const Image *image, const unsigned int gray, double azimuth,
                       double elevation, ExceptionInfo *exception );

image:
  The image.
gray:
  A value other than zero shades the intensity of each pixel.
azimuth, elevation:
  Define the light source direction.
exception:
  Return any errors or warnings in this structure.

# SharpenImage

## Synopsis

    Image *SharpenImage( const Image *image, const double radius, const double sigma,
                         ExceptionInfo *exception );

## Description

SharpenImage() sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and SharpenImage() selects a suitable radius for you.

The format of the SharpenImage method is:

    Image *SharpenImage( const Image *image, const double radius, const double sigma,
                         ExceptionInfo *exception );

image:
  The image.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Laplacian, in pixels.
exception:
  Return any errors or warnings in this structure.

# SharpenImageChannel

## Synopsis

    Image *SharpenImageChannel( const Image *image, const ChannelType channel,
                                const double radius, const double sigma,
                                ExceptionInfo *exception );

## Description

SharpenImageChannel() sharpens an image channel. We convolve the image channel with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and SharpenImageChannel() selects a suitable radius for you.

The format of the SharpenImageChannel method is:

    Image *SharpenImageChannel( const Image *image, const ChannelType channel,
                                const double radius, const double sigma,
                                ExceptionInfo *exception );

image:
  The image.
channel:
  The channel to sharpen.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Laplacian, in pixels.
exception:
  Return any errors or warnings in this structure.

# SpreadImage

## Synopsis

    Image *SpreadImage( const Image *image, const unsigned int radius,
                        ExceptionInfo *exception );

## Description

SpreadImage() is a special effects method that randomly displaces each pixel in a block defined by the radius parameter.

The format of the SpreadImage method is:

    Image *SpreadImage( const Image *image, const unsigned int radius,
                        ExceptionInfo *exception );

image:
  The image.
radius:
  Choose a random pixel in a neighborhood of this extent.
exception:
  Return any errors or warnings in this structure.

# ThresholdImage

## Synopsis

    MagickPassFail ThresholdImage( Image *image, const double threshold );

## Description

ThresholdImage() changes the value of individual pixels based on the intensity of each pixel compared to a specified threshold. Values greater than the threshold are set to the maximum quantum value, and values equal to or below the threshold are set to the minimum quantum value. The result is a high-contrast, two color image.

The format of the ThresholdImage method is:

    MagickPassFail ThresholdImage( Image *image, const double threshold );

A description of each parameter follows:

image:
  The image.
threshold:
  Define the threshold value

# UnsharpMaskImage

## Synopsis

    Image *UnsharpMaskImage( const Image *image, const double radius, const double sigma,
                             const double amount, const double threshold,
                             ExceptionInfo *exception );

## Description

UnsharpMaskImage() sharpens an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and UnsharpMaskImage() selects a suitable radius for you.

The format of the UnsharpMaskImage method is:

    Image *UnsharpMaskImage( const Image *image, const double radius, const double sigma,
                             const double amount, const double threshold,
                             ExceptionInfo *exception );

image:
  The image.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Gaussian, in pixels.
amount:
  The percentage of the difference between the original and the blur image that is added back into the original.
threshold:
  The threshold in pixels needed to apply the diffence amount.
exception:
  Return any errors or warnings in this structure.

# UnsharpMaskImageChannel

## Synopsis

    Image *UnsharpMaskImageChannel( const Image *image, const ChannelType channel,
                                    const double radius, const double sigma, const double amount,
                                    const double threshold, ExceptionInfo *exception );

## Description

UnsharpMaskImageChannel() sharpens an image channel. We convolve the image channel with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and UnsharpMaskImage() selects a suitable radius for you.

The format of the UnsharpMaskImageChannel method is:

    Image *UnsharpMaskImageChannel( const Image *image, const ChannelType channel,
                                    const double radius, const double sigma, const double amount,
                                    const double threshold, ExceptionInfo *exception );

image:
  The image.
channel:
  The channel to sharpen.
radius:
  The radius of the Gaussian, in pixels, not counting the center pixel.
sigma:
  The standard deviation of the Gaussian, in pixels.
amount:
  The percentage of the difference between the original and the blur image that is added back into the original.
threshold:
  The threshold in pixels needed to apply the diffence amount.
exception:
  Return any errors or warnings in this structure.

# WhiteThresholdImage

## Synopsis

    MagickPassFail WhiteThresholdImage( Image *image, const char *thresholds );

## Description

WhiteThresholdImage() adjusts the levels of image channels such that values above a specified threshold are set to the maximum value (white) while the remaining pixels are unchanged.

The format of the WhiteThresholdImage method is:

    MagickPassFail WhiteThresholdImage( Image *image, const char *thresholds );

A description of each parameter follows:

image:
  The image.
thresholds:
  Channel thresholds which are specified as a comma delimited list containing the thresholds for red, green, blue, and opacity. If the list contains a percent symbol (%) then all values are treated as a percentage of MaxRGB.

Copyright © GraphicsMagick Group 2002 - 2021