Table of Contents

Class Imaging.Processing

Namespace
Ranorex
Assembly
Ranorex.Core.dll

Provides low-level image processing routines.

public class Imaging.Processing
Inheritance
Imaging.Processing
Inherited Members

Constructors

Processing()

public Processing()

Properties

LaplaceKernel3x3

Gets a 3x3 laplace filter kernel.

public static int[,] LaplaceKernel3x3 { get; }

Property Value

int[,]

LaplaceKernel5x5

Gets a 5x5 laplace filter kernel.

public static int[,] LaplaceKernel5x5 { get; }

Property Value

int[,]

Methods

ConvertRgbToGrayscaleImage(Bitmap)

Converts a color to a grayscale image (bitmap format Format8bppIndexed).

public static Bitmap ConvertRgbToGrayscaleImage(Bitmap input)

Parameters

input Bitmap

A color image.

Returns

Bitmap

A grayscale image.

Remarks

This method is equivalent to method ConvertRgbToGrayscaleImageY(Bitmap).

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ConvertRgbToGrayscaleImage(Bitmap, double, double, double)

Converts a color to a grayscale image (bitmap format Format8bppIndexed) by calculating grayscale values according to the specified color component coefficients.

public static Bitmap ConvertRgbToGrayscaleImage(Bitmap input, double coeffR, double coeffG, double coeffB)

Parameters

input Bitmap

A color image.

coeffR double

The coefficient for the red color component.

coeffG double

The coefficient for the green color component.

coeffB double

The coefficient for the blue color component.

Returns

Bitmap

A grayscale image.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ConvertRgbToGrayscaleImageBT709(Bitmap)

Converts a color to a grayscale image (bitmap format Format8bppIndexed) using color component coefficients specified by the ITU-R Recommendation BT.709: { 0.2126, 0.7152, 0.0722 }.

public static Bitmap ConvertRgbToGrayscaleImageBT709(Bitmap input)

Parameters

input Bitmap

A color image.

Returns

Bitmap

A grayscale image.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ConvertRgbToGrayscaleImageRMY(Bitmap)

Converts a color to a grayscale image (bitmap format Format8bppIndexed) using color component coefficients { 0.5, 0.419, 0.081 }.

public static Bitmap ConvertRgbToGrayscaleImageRMY(Bitmap input)

Parameters

input Bitmap

A color image.

Returns

Bitmap

A grayscale image.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ConvertRgbToGrayscaleImageY(Bitmap)

Converts a color to a grayscale image (bitmap format Format8bppIndexed) using color component coefficients specified by the ITU-R Recommendation BT.601: { 0.299, 0.587, 0.114 }.

public static Bitmap ConvertRgbToGrayscaleImageY(Bitmap input)

Parameters

input Bitmap

A color image.

Returns

Bitmap

A grayscale image.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

DetectClickRegion(Bitmap, Rectangle, out Rectangle)

Tries to find a region in the image containing useful information by iterative inflation of the start rectangle. The algorithm stops if no more information is gained through inflation.

public static Bitmap DetectClickRegion(Bitmap input, Rectangle startRect, out Rectangle result)

Parameters

input Bitmap

The input image.

startRect Rectangle

The start region.

result Rectangle

The resulting region.

Returns

Bitmap

The resulting detected region. Returns a empty region if the information content in the region is too low.

DetectEdges(Bitmap)

Converts the input images to a grayscale image that contains object edges from the input image.

public static Bitmap DetectEdges(Bitmap input)

Parameters

input Bitmap

An image.

Returns

Bitmap

A grayscale image containing object edges.

Remarks

This method is equivalent to DetectEdgesLaplace(Bitmap).

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

DetectEdgesLaplace(Bitmap)

Converts the input images to a grayscale image that contains object edges from the input image using a Laplace filter kernel.

public static Bitmap DetectEdgesLaplace(Bitmap input)

Parameters

input Bitmap

An image.

Returns

Bitmap

A grayscale image containing object edges.

Remarks

By default the LaplaceKernel5x5 is used as the filter kernel, unless the image with or height is smaller than 5 pixels; in that case the LaplaceKernel3x3 is used instead.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

DetectEdgesLaplace(Bitmap, bool, out int)

Converts the input images to a grayscale image that contains object edges from the input image using a Laplace filter kernel, optionally scaling grayscale values in the output image.

public static Bitmap DetectEdgesLaplace(Bitmap input, bool scale, out int margin)

Parameters

input Bitmap

An image.

scale bool

If true, the FilterScaled(Bitmap, int[,]) method is used to filter the input image; otherwise the Filter(Bitmap, int[,]) method is used.

margin int

When this method returns, contains an integer that specifies the pixel margin in the output image that has not been written to because of the filter size.

Returns

Bitmap

A grayscale image containing object edges.

Remarks

By default the LaplaceKernel5x5 is used as the filter kernel, unless the image with or height is smaller than 5 pixels; in that case the LaplaceKernel3x3 is used instead.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

DetectEdgesSobel(Bitmap)

Converts the input images to a grayscale image that contains object edges from the input image using the Sobel filtering algorithm.

public static Bitmap DetectEdgesSobel(Bitmap input)

Parameters

input Bitmap

An image.

Returns

Bitmap

A grayscale image containing object edges.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

Filter(Bitmap, int[,])

Creates a new grayscale image by applying the specified filter kernel on the input image.

public static Bitmap Filter(Bitmap input, int[,] filterKernel)

Parameters

input Bitmap

An image.

filterKernel int[,]

The filter kernel used to filter the input image.

Returns

Bitmap

A grayscale image filtered by the specified filter kernel.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ArgumentException

If filterKernel is not a 3x3 or 5x5 filter kernel.

FilterScaled(Bitmap, int[,])

Creates a new grayscale image by applying the specified filter kernel on the input image. The grayscale values in the output image are scaled to avoid cropping, i.e. so that no output value is smaller than zero or greather than 255.

public static Bitmap FilterScaled(Bitmap input, int[,] filterKernel)

Parameters

input Bitmap

An image.

filterKernel int[,]

The filter kernel used to filter the input image.

Returns

Bitmap

A grayscale image filtered by the specified filter kernel.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

ArgumentException

If filterKernel is not a 3x3 or 5x5 filter kernel.

FindImage(Bitmap, Bitmap, double, int, int, bool[,])

Searches for the specified feature in the image and returns a list of Imaging.Matches.

public static List<Imaging.Match> FindImage(Bitmap image, Bitmap feature, double similarityThreshold, int windowRadius, int maxMatches, bool[,] ignoreMap = null)

Parameters

image Bitmap

The image to search in.

feature Bitmap

The image to search for.

similarityThreshold double

A value between 0.0 and 1.0 (inclusive) that defines the similarity the feature needs to have with the image to be considered a match.

windowRadius int

Specifies the radius of a window in which only the match with the greatest similarity is reported.

maxMatches int

Defines the maximum number of matches to return; or 0 to not define a limit for the number of matches.

ignoreMap bool[,]

A two dimensional map of the reference image pixels. Is the pixel set to true in this map it will be ignored for comparison.

Returns

List<Imaging.Match>

A list of Imaging.Matches found.

Exceptions

ArgumentNullException

If image is null.

ArgumentNullException

If feature is null.

ArgumentOutOfRangeException

If similarityThreshold lies outside the interval 0.0 and 1.0.

ArgumentOutOfRangeException

If maxMatches is negative.

ArgumentException

If the feature is greater in size than the image.

ArgumentException

If the bitmap format of the feature cannot be converted to that of the image.

Preprocess(Bitmap, bool, bool, bool, double, double)

Preprocesses the specified image by converting it to a grayscale image, detecting object edges, thresholding, and/or resizing/scaling it.

public static Bitmap Preprocess(Bitmap image, bool grayscale, bool edges, bool threshold, double scaleWidth, double scaleHeight)

Parameters

image Bitmap

An image.

grayscale bool

If true and image is not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).

edges bool

If true, tries to detect object edges in the image (see DetectEdges(Bitmap)).

threshold bool

If true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).

scaleWidth double

If not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

scaleHeight double

If not equal to 1.0, the height of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

Returns

Bitmap

The preprocessed image.

Exceptions

ArgumentNullException

If image is null.

ArgumentException

If the input image is not a grayscale image, needs to be converted to such, and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

Preprocess(Bitmap, bool, ref bool, bool, bool, double, double, out Point)

Preprocesses the specified image by converting it to a grayscale image, detecting object edges, thresholding, and/or resizing/scaling it.

public static Bitmap Preprocess(Bitmap image, bool grayscale, ref bool edges, bool useSobel, bool threshold, double scaleWidth, double scaleHeight, out Point offset)

Parameters

image Bitmap

An image.

grayscale bool

If true and image is not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).

edges bool

If true, tries to detect object edges in the image (see DetectEdges(Bitmap)). If the image width or height is smaller than 3 pixels, no edge detection will be performed and this parameter will be false when the method returns.

useSobel bool

Decides which edge detection algorithm to use if edges is true. If true, the Sobel edge detection algorithm is used (see DetectEdgesSobel(Bitmap)), otherwise Laplace is used (see DetectEdgesLaplace(Bitmap)).

threshold bool

If true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).

scaleWidth double

If not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

scaleHeight double

If not equal to 1.0, the height of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

offset Point

When this method returns, contains a point that specifies the number of pixels the image has been cropped. Cropping takes place to remove a margin that comes from applying an edge detection filter on the image.

Returns

Bitmap

The preprocessed image.

Exceptions

ArgumentNullException

If image is null.

ArgumentException

If the input image is not a grayscale image, needs to be converted to such, and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

Preprocess(Bitmap, bool, ref bool, bool, double, double, out Point)

Preprocesses the specified image by converting it to a grayscale image, detecting object edges, thresholding, and/or resizing/scaling it.

public static Bitmap Preprocess(Bitmap image, bool grayscale, ref bool edges, bool threshold, double scaleWidth, double scaleHeight, out Point offset)

Parameters

image Bitmap

An image.

grayscale bool

If true and image is not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).

edges bool

If true, tries to detect object edges in the image (see DetectEdges(Bitmap)). If the image width or height is smaller than 3 pixels, no edge detection will be performed and this parameter will be false when the method returns.

threshold bool

If true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).

scaleWidth double

If not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

scaleHeight double

If not equal to 1.0, the height of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).

offset Point

When this method returns, contains a point that specifies the number of pixels the image has been cropped. Cropping takes place to remove a margin that comes from applying an edge detection filter on the image.

Returns

Bitmap

The preprocessed image.

Exceptions

ArgumentNullException

If image is null.

ArgumentException

If the input image is not a grayscale image, needs to be converted to such, and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).

Threshold(Bitmap, byte)

Converts the input image to a black/white image (i.e. an image that contains only two different colors) using the specified threshold value.

public static Bitmap Threshold(Bitmap input, byte threshold)

Parameters

input Bitmap

An image.

threshold byte

The threshold value that decides whether an output pixel is colored black or white. If the input value is smaller than the threshold, the output pixel is colored black, otherwise white.

Returns

Bitmap

A grayscale image that contains only black and white pixels.

Remarks

If the image is not a grayscale image, it will be converted using the ConvertRgbToGrayscaleImage(Bitmap) method.

Exceptions

ArgumentNullException

If input is null.

ArgumentException

If the input image is not a grayscale image and cannot be converted to Format24bppRgb pixel format (i.e. if it is no color image in a 32 bit format).