Threshold



AdaptiveThresholdImage

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(const Image *image,const size_t width,
  const size_t height,const double bias,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
width
the width of the local neighborhood.
height
the height of the local neighborhood.
bias
the mean bias.
exception
return any errors or warnings in this structure.

AutoThresholdImage

AutoThresholdImage() automatically performs image thresholding dependent on which method you specify.

The format of the AutoThresholdImage method is:

MagickBooleanType AutoThresholdImage(Image *image,
  const AutoThresholdMethod method,ExceptionInfo *exception)

A description of each parameter follows:

image
The image to auto-threshold.
method
choose from Kapur, OTSU, or Triangle.
exception
return any errors or warnings in this structure.

BilevelImage

BilevelImage() changes the value of individual pixels based on the intensity of each pixel channel. The result is a high-contrast image.

More precisely each channel value of the image is 'thresholded' so that if it is equal to or less than the given value it is set to zero, while any value greater than that give is set to it maximum or QuantumRange.

This function is what is used to implement the "-threshold" operator for the command line API.

If the default channel setting is given the image is thresholded using just the gray 'intensity' of the image, rather than the individual channels.

The format of the BilevelImage method is:

MagickBooleanType BilevelImage(Image *image,const double threshold,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
threshold
define the threshold values.
exception
return any errors or warnings in this structure.
Aside: You can get the same results as operator using LevelImages() with the 'threshold' value for both the black_point and the white_point.

BlackThresholdImage

BlackThresholdImage() is like ThresholdImage() but forces all pixels below the threshold into black while leaving all pixels at or above the threshold unchanged.

The format of the BlackThresholdImage method is:

MagickBooleanType BlackThresholdImage(Image *image,
  const char *threshold,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
threshold
define the threshold value.
exception
return any errors or warnings in this structure.

ClampImage

ClampImage() set each pixel whose value is below zero to zero and any the pixel whose value is above the quantum range to the quantum range (e.g. 65535) otherwise the pixel value remains unchanged.

The format of the ClampImage method is:

MagickBooleanType ClampImage(Image *image,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
exception
return any errors or warnings in this structure.

ColorThresholdImage

ColorThresholdImage() forces all pixels in the color range to white otherwise black.

The format of the ColorThresholdImage method is:

MagickBooleanType ColorThresholdImage(Image *image,
  const PixelInfo *start_color,const PixelInfo *stop_color,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
start_color, stop_color
define the start and stop color range. Any pixel within the range returns white otherwise black.
exception
return any errors or warnings in this structure.

DestroyThresholdMap

DestroyThresholdMap() de-allocate the given ThresholdMap

The format of the ListThresholdMaps method is:

ThresholdMap *DestroyThresholdMap(Threshold *map)

A description of each parameter follows.

map

Pointer to the Threshold map to destroy

GetThresholdMap

GetThresholdMap() loads and searches one or more threshold map files for the map matching the given name or alias.

The format of the GetThresholdMap method is:

ThresholdMap *GetThresholdMap(const char *map_id,
  ExceptionInfo *exception)

A description of each parameter follows.

map_id

ID of the map to look for.

exception

return any errors or warnings in this structure.

ListThresholdMaps

ListThresholdMaps() lists the threshold maps and their descriptions as defined by "threshold.xml" to a file.

The format of the ListThresholdMaps method is:

MagickBooleanType ListThresholdMaps(FILE *file,ExceptionInfo *exception)

A description of each parameter follows.

file

An pointer to the output FILE.

exception

return any errors or warnings in this structure.

OrderedDitherImage

OrderedDitherImage() will perform a ordered dither based on a number of pre-defined dithering threshold maps, but over multiple intensity levels, which can be different for different channels, according to the input argument.

The format of the OrderedDitherImage method is:

MagickBooleanType OrderedDitherImage(Image *image,
  const char *threshold_map,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
threshold_map
A string containing the name of the threshold dither map to use, followed by zero or more numbers representing the number of color levels to dither between.
Any level number less than 2 will be equivalent to 2, and means only binary dithering will be applied to each color channel.
No numbers also means a 2 level (bitmap) dither will be applied to all channels, while a single number is the number of levels applied to each channel in sequence. More numbers will be applied in turn to each of the color channels.
For example: "o3x3,6" will generate a 6 level posterization of the image with an ordered 3x3 diffused pixel dither being applied between each level. While checker,8,8,4 will produce a 332 colormaped image with only a single checkerboard hash pattern (50 grey) between each color level, to basically double the number of color levels with a bare minimum of dithering.
exception
return any errors or warnings in this structure.

PerceptibleImage

PerceptibleImage() set each pixel whose value is less than |epsilon| to epsilon or -epsilon (whichever is closer) otherwise the pixel value remains unchanged.

The format of the PerceptibleImage method is:

MagickBooleanType PerceptibleImage(Image *image,const double epsilon,
  ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
epsilon
the epsilon threshold (e.g. 1.0e-9).
exception
return any errors or warnings in this structure.

RandomThresholdImage

RandomThresholdImage() 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 RandomThresholdImage method is:

MagickBooleanType RandomThresholdImage(Image *image,
  const char *thresholds,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
low,high
Specify the high and low thresholds. These values range from 0 to QuantumRange.
exception
return any errors or warnings in this structure.

RangeThresholdImage

RangeThresholdImage() applies soft and hard thresholding.

The format of the RangeThresholdImage method is:

MagickBooleanType RangeThresholdImage(Image *image,
  const double low_black,const double low_white,const double high_white,
  const double high_black,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
low_black
Define the minimum black threshold value.
low_white
Define the minimum white threshold value.
high_white
Define the maximum white threshold value.
high_black
Define the maximum black threshold value.
exception
return any errors or warnings in this structure.

WhiteThresholdImage

WhiteThresholdImage() is like ThresholdImage() but forces all pixels above the threshold into white while leaving all pixels at or below the threshold unchanged.

The format of the WhiteThresholdImage method is:

MagickBooleanType WhiteThresholdImage(Image *image,
  const char *threshold,ExceptionInfo *exception)

A description of each parameter follows:

image
the image.
threshold
Define the threshold value.
exception
return any errors or warnings in this structure.