- Main Page
- Modules
- Classes
- Files

# DSP

## Enumerations
enum | CxImage::ImageOpType { CxImage::OpAdd, CxImage::OpAnd, CxImage::OpXor, CxImage::OpOr, CxImage::OpMask, CxImage::OpSrcCopy, CxImage::OpDstCopy, CxImage::OpSub, CxImage::OpSrcBlend, CxImage::OpScreen, CxImage::OpAvg, CxImage::OpBlendAlpha }
## Functions
bool | CxImage::Contour ()
bool | CxImage::HistogramStretch (int32_t method=0, double threshold=0)
bool | CxImage::HistogramEqualize ()
bool | CxImage::HistogramNormalize ()
bool | CxImage::HistogramRoot ()
bool | CxImage::HistogramLog ()
int32_t | CxImage::Histogram (int32_t *red, int32_t *green=0, int32_t *blue=0, int32_t *gray=0, int32_t colorspace=0)
bool | CxImage::Jitter (int32_t radius=2)
bool | CxImage::Repair (float radius=0.25f, int32_t niterations=1, int32_t colorspace=0)
bool | CxImage::Combine (CxImage *r, CxImage *g, CxImage *b, CxImage *a, int32_t colorspace=0)
bool | CxImage::FFT2 (CxImage *srcReal, CxImage *srcImag, CxImage *dstReal, CxImage *dstImag, int32_t direction=1, bool bForceFFT=true, bool bMagnitude=true)
bool | CxImage::Noise (int32_t level)
bool | CxImage::Median (int32_t Ksize=3)
bool | CxImage::Gamma (float gamma)
bool | CxImage::GammaRGB (float gammaR, float gammaG, float gammaB)
bool | CxImage::ShiftRGB (int32_t r, int32_t g, int32_t b)
bool | CxImage::Threshold (uint8_t level)
bool | CxImage::Threshold (CxImage *pThresholdMask)
bool | CxImage::Threshold2 (uint8_t level, bool bDirection, RGBQUAD nBkgndColor, bool bSetAlpha=false)
bool | CxImage::Colorize (uint8_t hue, uint8_t sat, float blend=1.0f)
bool | CxImage::Light (int32_t brightness, int32_t contrast=0)
float | CxImage::Mean ()
bool | CxImage::Filter (int32_t *kernel, int32_t Ksize, int32_t Kfactor, int32_t Koffset)
bool | CxImage::Erode (int32_t Ksize=2)
bool | CxImage::Dilate (int32_t Ksize=2)
bool | CxImage::Edge (int32_t Ksize=2)
void | CxImage::HuePalette (float correction=1)
void | CxImage::Mix (CxImage &imgsrc2, ImageOpType op, int32_t lXOffset=0, int32_t lYOffset=0, bool bMixAlpha=false)
void | CxImage::MixFrom (CxImage &imagesrc2, int32_t lXOffset, int32_t lYOffset)
bool | CxImage::UnsharpMask (float radius=5.0f, float amount=0.5f, int32_t threshold=0)
bool | CxImage::Lut (uint8_t *pLut)
bool | CxImage::Lut (uint8_t *pLutR, uint8_t *pLutG, uint8_t *pLutB, uint8_t *pLutA=0)
bool | CxImage::GaussianBlur (float radius=1.0f, CxImage *iDst=0)
bool | CxImage::TextBlur (uint8_t threshold=100, uint8_t decay=2, uint8_t max_depth=5, bool bBlurHorizontal=true, bool bBlurVertical=true, CxImage *iDst=0)
bool | CxImage::SelectiveBlur (float radius=1.0f, uint8_t threshold=25, CxImage *iDst=0)
bool | CxImage::Solarize (uint8_t level=128, bool bLinkedChannels=true)
bool | CxImage::FloodFill (const int32_t xStart, const int32_t yStart, const RGBQUAD cFillColor, const uint8_t tolerance=0, uint8_t nOpacity=255, const bool bSelectFilledArea=false, const uint8_t nSelectionLevel=255)
bool | CxImage::Saturate (const int32_t saturation, const int32_t colorspace=1)
bool | CxImage::ConvertColorSpace (const int32_t dstColorSpace, const int32_t srcColorSpace)
int32_t | CxImage::OptimalThreshold (int32_t method=0, RECT *pBox=0, CxImage *pContrastMask=0)
bool | CxImage::AdaptiveThreshold (int32_t method=0, int32_t nBoxSize=64, CxImage *pContrastMask=0, int32_t nBias=0, float fGlobalLocalBalance=0.5f)
bool | CxImage::RedEyeRemove (float strength=0.8f)
bool | CxImage::Trace (RGBQUAD color_target, RGBQUAD color_trace)

## Detailed Description

## Enumeration Type Documentation

enum CxImage::ImageOpType`[inherited]`

Enumerator:

  OpAdd |
  OpAnd |
  OpXor |
  OpOr |
  OpMask |
  OpSrcCopy |
  OpDstCopy |
  OpSub |
  OpSrcBlend |
  OpScreen |
  OpAvg |
  OpBlendAlpha |

## Function Documentation

bool CxImage::AdaptiveThreshold | ( | int32_t | method = `0`,
|  | int32_t | nBoxSize = `64`,
|  | CxImage * | pContrastMask = `0`,
|  | int32_t | nBias = `0`,
|  | float | fGlobalLocalBalance = `0.5f` |
| ) |  |  | `[inherited]`

Converts the image to B&W, using an optimal threshold mask

Parameters:

  | method,: | 0 = average all methods (default); 1 = Otsu; 2 = Kittler & Illingworth; 3 = max entropy; 4 = potential difference;
  | nBoxSize,: | the image is divided into "nBoxSize x nBoxSize" blocks, from where the threshold is computed; min = 8; default = 64.
  | pContrastMask,: | limit the computation only in regions with contrasted (!=0) pixels; default = 0.
  | nBias,: | global offset added to the threshold mask; default = 0.
  | fGlobalLocalBalance,: | balance between local and global threshold. default = 0.5 fGlobalLocalBalance can be from 0.0 (use only local threshold) to 1.0 (use only global threshold) the pContrastMask image must be grayscale with same with and height of the current image,

Returns:
  true if everything is ok.

See also:
  OptimalThreshold

bool CxImage::Colorize | ( | uint8_t | hue,
|  | uint8_t | sat,
|  | float | blend = `1.0f` |
| ) |  |  | `[inherited]`

Replaces the original hue and saturation values.

Parameters:

  | hue,: | hue
  | sat,: | saturation
  | blend,: | can be from 0 (no effect) to 1 (full effect)

Returns:
  true if everything is ok

bool CxImage::Combine | ( | CxImage * | r,
|  | CxImage * | g,
|  | CxImage * | b,
|  | CxImage * | a,
|  | int32_t | colorspace = `0` |
| ) |  |  | `[inherited]`

Combines different color components into a single image

Parameters:

  | r,g,b,: | color channels
  | a,: | alpha layer, can be NULL
  | colorspace,: | 0 = RGB, 1 = HSL, 2 = YUV, 3 = YIQ, 4 = XYZ

Returns:
  true if everything is ok

bool CxImage::Contour | ( |  | ) | `[inherited]`

Enhance the variations between adjacent pixels. Similar results can be achieved using Filter(), but the algorithms are different both in Edge() and in Contour().

Returns:
  true if everything is ok

bool CxImage::ConvertColorSpace | ( | const int32_t | dstColorSpace,
|  | const int32_t | srcColorSpace |
| ) |  |  | `[inherited]`

Converts the RGB triplets to and from different colorspace

Parameters:

  | dstColorSpace,: | destination colorspace; 0 = RGB, 1 = HSL, 2 = YUV, 3 = YIQ, 4 = XYZ
  | srcColorSpace,: | source colorspace; 0 = RGB, 1 = HSL, 2 = YUV, 3 = YIQ, 4 = XYZ

Returns:
  true if everything is ok

bool CxImage::Dilate | ( | int32_t | Ksize = `2` | ) | `[inherited]`

Enhance the light areas of the image

Parameters:

  | Ksize,: | size of the kernel.

Returns:
  true if everything is ok

bool CxImage::Edge | ( | int32_t | Ksize = `2` | ) | `[inherited]`

Enhance the variations between adjacent pixels. Similar results can be achieved using Filter(), but the algorithms are different both in Edge() and in Contour().

Parameters:

  | Ksize,: | size of the kernel.

Returns:
  true if everything is ok

bool CxImage::Erode | ( | int32_t | Ksize = `2` | ) | `[inherited]`

Enhance the dark areas of the image

Parameters:

  | Ksize,: | size of the kernel.

Returns:
  true if everything is ok

bool CxImage::FFT2 | ( | CxImage * | srcReal,
|  | CxImage * | srcImag,
|  | CxImage * | dstReal,
|  | CxImage * | dstImag,
|  | int32_t | direction = `1`,
|  | bool | bForceFFT = `true`,
|  | bool | bMagnitude = `true` |
| ) |  |  | `[inherited]`

Computes the bidimensional FFT or DFT of the image.

- The images are processed as grayscale
- If the dimensions of the image are a power of, 2 the FFT is performed automatically.
- If dstReal and/or dstImag are NULL, the resulting images replaces the original(s).
- Note: with 8 bits there is a HUGE loss in the dynamics. The function tries to keep an acceptable SNR, but 8bit = 48dB...

Parameters:

  | srcReal,srcImag,: | source images: One can be NULL, but not both
  | dstReal,dstImag,: | destination images. Can be NULL.
  | direction,: | 1 = forward, -1 = inverse.
  | bForceFFT,: | if true, the images are resampled to make the dimensions a power of 2.
  | bMagnitude,: | if true, the real part returns the magnitude, the imaginary part returns the phase

Returns:
  true if everything is ok

bool CxImage::Filter | ( | int32_t * | kernel,
|  | int32_t | Ksize,
|  | int32_t | Kfactor,
|  | int32_t | Koffset |
| ) |  |  | `[inherited]`

2D linear filter

Parameters:

  | kernel,: | convolving matrix, in row format.
  | Ksize,: | size of the kernel.
  | Kfactor,: | normalization constant.
  | Koffset,: | bias.
      Example: the "soften" filter uses this kernel:
      	1 1 1
      	1 8 1
      	1 1 1
       the function needs: kernel={1,1,1,1,8,1,1,1,1}; Ksize=3; Kfactor=16; Koffset=0;

Returns:
  true if everything is ok

bool CxImage::FloodFill | ( | const int32_t | xStart,
|  | const int32_t | yStart,
|  | const RGBQUAD | cFillColor,
|  | const uint8_t | nTolerance = `0`,
|  | uint8_t | nOpacity = `255`,
|  | const bool | bSelectFilledArea = `false`,
|  | const uint8_t | nSelectionLevel = `255` |
| ) |  |  | `[inherited]`

Flood Fill

Parameters:

  | xStart,yStart,: | starting point
  | cFillColor,: | filling color
  | nTolerance,: | deviation from the starting point color
  | nOpacity,: | can be from 0 (transparent) to 255 (opaque, default)
  | bSelectFilledArea,: | if true, the pixels in the region are also set in the selection layer; default = false
  | nSelectionLevel,: | if bSelectFilledArea is true, the selected pixels are set to nSelectionLevel; default = 255 Note: nOpacity=0 && bSelectFilledArea=true act as a "magic wand"

Returns:
  true if everything is ok

bool CxImage::Gamma | ( | float | gamma | ) | `[inherited]`

Adjusts the color balance of the image

Parameters:

  | gamma | can be from 0.1 to 5.

Returns:
  true if everything is ok

See also:
  GammaRGB

bool CxImage::GammaRGB | ( | float | gammaR,
|  | float | gammaG,
|  | float | gammaB |
| ) |  |  | `[inherited]`

Adjusts the color balance indipendent for each color channel

Parameters:

  | gammaR,gammaG,gammaB | can be from 0.1 to 5.

Returns:
  true if everything is ok

See also:
  Gamma

bool CxImage::GaussianBlur | ( | float | radius = `1.0f`,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

Author:
  [nipper]; changes [DP]

int32_t CxImage::Histogram | ( | int32_t * | red,
|  | int32_t * | green = `0`,
|  | int32_t * | blue = `0`,
|  | int32_t * | gray = `0`,
|  | int32_t | colorspace = `0` |
| ) |  |  | `[inherited]`

bool CxImage::HistogramEqualize | ( |  | ) | `[inherited]`

bool CxImage::HistogramLog | ( |  | ) | `[inherited]`

bool CxImage::HistogramNormalize | ( |  | ) | `[inherited]`

bool CxImage::HistogramRoot | ( |  | ) | `[inherited]`

bool CxImage::HistogramStretch | ( | int32_t | method = `0`,
|  | double | threshold = `0` |
| ) |  |  | `[inherited]`

HistogramStretch

Parameters:

  | method,: | 0 = luminance (default), 1 = linked channels , 2 = independent channels.
  | threshold,: | minimum percentage level in the histogram to recognize it as meaningful. Range: 0.0 to 1.0; default = 0; typical = 0.005 (0.5%);

Returns:
  true if everything is ok

Author:
  [dave] and [nipper]; changes [DP]

void CxImage::HuePalette | ( | float | correction = `1` | ) | `[inherited]`

Generates a "rainbow" palette with saturated colors

Parameters:

  | correction,: | 1 generates a single hue spectrum. 0.75 is nice for scientific applications.

bool CxImage::Jitter | ( | int32_t | radius = `2` | ) | `[inherited]`

Adds a random offset to each pixel in the image

Parameters:

  | radius,: | maximum pixel displacement

Returns:
  true if everything is ok

bool CxImage::Light | ( | int32_t | brightness,
|  | int32_t | contrast = `0` |
| ) |  |  | `[inherited]`

Changes the brightness and the contrast of the image.

Parameters:

  | brightness,: | can be from -255 to 255, if brightness is negative, the image becomes dark.
  | contrast,: | can be from -100 to 100, the neutral value is 0.

Returns:
  true if everything is ok

bool CxImage::Lut | ( | uint8_t * | pLutR,
|  | uint8_t * | pLutG,
|  | uint8_t * | pLutB,
|  | uint8_t * | pLutA = `0` |
| ) |  |  | `[inherited]`

Apply an indipendent look up table for each channel

Parameters:

  | pLutR,pLutG,pLutB,pLutA,: | uint8_t[256] look up tables

Returns:
  true if everything is ok

bool CxImage::Lut | ( | uint8_t * | pLut | ) | `[inherited]`

Apply a look up table to the image.

Parameters:

  | pLut,: | uint8_t[256] look up table

Returns:
  true if everything is ok

float CxImage::Mean | ( |  | ) | `[inherited]`

Returns:
  mean lightness of the image. Useful with Threshold() and Light()

bool CxImage::Median | ( | int32_t | Ksize = `3` | ) | `[inherited]`

Adjusts the intensity of each pixel to the median intensity of its surrounding pixels.

Parameters:

  | Ksize,: | size of the kernel.

Returns:
  true if everything is ok

void CxImage::Mix | ( | CxImage & | imgsrc2,
|  | ImageOpType | op,
|  | int32_t | lXOffset = `0`,
|  | int32_t | lYOffset = `0`,
|  | bool | bMixAlpha = `false` |
| ) |  |  | `[inherited]`

Blends two images

Parameters:

  | imgsrc2,: | image to be mixed with this
  | op,: | blending method; see ImageOpType
  | lXOffset,lYOffset,: | image displacement
  | bMixAlpha,: | if true and imgsrc2 has a valid alpha layer, it will be mixed in the destination image.

Returns:
  true if everything is ok

Author:
  [Mwolski],[brunom]

void CxImage::MixFrom | ( | CxImage & | imagesrc2,
|  | int32_t | lXOffset,
|  | int32_t | lYOffset |
| ) |  |  | `[inherited]`

bool CxImage::Noise | ( | int32_t | level | ) | `[inherited]`

Adds an uniform noise to the image

Parameters:

  | level,: | can be from 0 (no noise) to 255 (lot of noise).

Returns:
  true if everything is ok

int32_t CxImage::OptimalThreshold | ( | int32_t | method = `0`,
|  | RECT * | pBox = `0`,
|  | CxImage * | pContrastMask = `0` |
| ) |  |  | `[inherited]`

Finds the optimal (global or local) treshold for image binarization

Parameters:

  | method,: | 0 = average all methods (default); 1 = Otsu; 2 = Kittler & Illingworth; 3 = max entropy; 4 = potential difference;
  | pBox,: | region from where the threshold is computed; 0 = full image (default).
  | pContrastMask,: | limit the computation only in regions with contrasted (!=0) pixels; default = 0. the pContrastMask image must be grayscale with same with and height of the current image, can be obtained from the current image with a filter: CxImage iContrastMask(*image,true,false,false); iContrastMask.GrayScale(); int32_t edge[]={-1,-1,-1,-1,8,-1,-1,-1,-1}; iContrastMask.Filter(edge,3,1,0); int32_t blur[]={1,1,1,1,1,1,1,1,1}; iContrastMask.Filter(blur,3,9,0);

Returns:
  optimal threshold; -1 = error.

See also:
  AdaptiveThreshold

bool CxImage::RedEyeRemove | ( | float | strength = `0.8f` | ) | `[inherited]`

Use the RedEyeRemove function to remove the red-eye effect that frequently occurs in photographs of humans and animals. You must select the region where the function will filter the red channel.

Parameters:

  | strength,: | range from 0.0f (no effect) to 1.0f (full effect). Default = 0.8

Returns:
  true if everything is ok

bool CxImage::Repair | ( | float | radius = `0.25f`,
|  | int32_t | niterations = `1`,
|  | int32_t | colorspace = `0` |
| ) |  |  | `[inherited]`

Smart blurring to remove small defects, dithering or artifacts.

Parameters:

  | radius,: | normally between 0.01 and 0.5
  | niterations,: | should be trimmed with radius, to avoid blurring should be (radius*niterations)<1
  | colorspace,: | 0 = RGB, 1 = HSL, 2 = YUV, 3 = YIQ, 4 = XYZ

Returns:
  true if everything is ok

bool CxImage::Saturate | ( | const int32_t | saturation,
|  | const int32_t | colorspace = `1` |
| ) |  |  | `[inherited]`

Changes the saturation of the image.

Parameters:

  | saturation,: | can be from -100 to 100, positive values increase the saturation.
  | colorspace,: | can be 1 (HSL) or 2 (YUV).

Returns:
  true if everything is ok

bool CxImage::SelectiveBlur | ( | float | radius = `1.0f`,
|  | uint8_t | threshold = `25`,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

Author:
  [DP],[nipper]

bool CxImage::ShiftRGB | ( | int32_t | r,
|  | int32_t | g,
|  | int32_t | b |
| ) |  |  | `[inherited]`

Adjusts separately the red, green, and blue values in the image.

Parameters:

  | r,g,b,: | can be from -255 to +255.

Returns:
  true if everything is ok

bool CxImage::Solarize | ( | uint8_t | level = `128`,
|  | bool | bLinkedChannels = `true` |
| ) |  |  | `[inherited]`

Solarize: convert all colors above a given lightness level into their negative

Parameters:

  | level | : lightness threshold. Range = 0 to 255; default = 128.
  | bLinkedChannels,: | true = compare with luminance, preserve colors (default) false = compare with independent R,G,B levels

Returns:
  true if everything is ok

Author:
  [Priyank Bolia] (priyank_bolia(at)yahoo(dot)com); changes [DP]

bool CxImage::TextBlur | ( | uint8_t | threshold = `100`,
|  | uint8_t | decay = `2`,
|  | uint8_t | max_depth = `5`,
|  | bool | bBlurHorizontal = `true`,
|  | bool | bBlurVertical = `true`,
|  | CxImage * | iDst = `0` |
| ) |  |  | `[inherited]`

Author:
  [DP]

bool CxImage::Threshold | ( | CxImage * | pThresholdMask | ) | `[inherited]`

Converts the image to B&W, using a threshold mask

Parameters:

  | pThresholdMask,: | the lightness threshold mask. the pThresholdMask image must be grayscale with same with and height of the current image

Returns:
  true if everything is ok

bool CxImage::Threshold | ( | uint8_t | level | ) | `[inherited]`

Converts the image to B&W. The OptimalThreshold() function can be used for calculating the optimal threshold.

Parameters:

  | level,: | the lightness threshold.

Returns:
  true if everything is ok

bool CxImage::Threshold2 | ( | uint8_t | level,
|  | bool | bDirection,
|  | RGBQUAD | nBkgndColor,
|  | bool | bSetAlpha = `false` |
| ) |  |  | `[inherited]`

Filters only the pixels with a lightness less (or more) than the threshold level, and preserves the colors for the unfiltered pixels.

Parameters:

  | level | = the lightness threshold.
  | bDirection | = false: filter dark pixels, true: filter light pixels
  | nBkgndColor | = filtered pixels are set to nBkgndColor color
  | bSetAlpha | = if true, sets also the alpha component for the filtered pixels, with nBkgndColor.rgbReserved

Returns:
  true if everything is ok

Author:
  [DP], [wangsongtao]

bool CxImage::Trace | ( | RGBQUAD | color_target,
|  | RGBQUAD | color_trace |
| ) |  |  | `[inherited]`

Finds the contour of an object with a given color

Parameters:

  | color_target,: | object color
  | color_trace,: | contour color

Returns:
  true if everything is ok.

See also:
  Edge, Contour

bool CxImage::UnsharpMask | ( | float | radius = `5.0f`,
|  | float | amount = `0.5f`,
|  | int32_t | threshold = `0` |
| ) |  |  | `[inherited]`

sharpen the image by subtracting a blurred copy from the original image.

Parameters:

  | radius,: | width in pixels of the blurring effect. Range: >0; default = 5.
  | amount,: | strength of the filter. Range: 0.0 (none) to 1.0 (max); default = 0.5
  | threshold,: | difference, between blurred and original pixel, to trigger the filter Range: 0 (always triggered) to 255 (never triggered); default = 0.

Returns:
  true if everything is ok

Author:
  [nipper]; changes [DP]