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
inputBitmapA color image.
Returns
- Bitmap
A grayscale image.
Remarks
This method is equivalent to method ConvertRgbToGrayscaleImageY(Bitmap).
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapA color image.
coeffRdoubleThe coefficient for the red color component.
coeffGdoubleThe coefficient for the green color component.
coeffBdoubleThe coefficient for the blue color component.
Returns
- Bitmap
A grayscale image.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapA color image.
Returns
- Bitmap
A grayscale image.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapA color image.
Returns
- Bitmap
A grayscale image.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapA color image.
Returns
- Bitmap
A grayscale image.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapThe input image.
startRectRectangleThe start region.
resultRectangleThe 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
inputBitmapAn image.
Returns
- Bitmap
A grayscale image containing object edges.
Remarks
This method is equivalent to DetectEdgesLaplace(Bitmap).
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapAn 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
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapAn image.
scaleboolIf
true, the FilterScaled(Bitmap, int[,]) method is used to filter the input image; otherwise the Filter(Bitmap, int[,]) method is used.marginintWhen 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
inputisnull.- ArgumentException
If the
inputimage 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
inputBitmapAn image.
Returns
- Bitmap
A grayscale image containing object edges.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
Returns
- Bitmap
A grayscale image filtered by the specified filter kernel.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
filterKernelis 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
Returns
- Bitmap
A grayscale image filtered by the specified filter kernel.
Exceptions
- ArgumentNullException
If
inputisnull.- ArgumentException
If the
inputimage 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
filterKernelis 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
imageBitmapThe image to search in.
featureBitmapThe image to search for.
similarityThresholddoubleA 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.
windowRadiusintSpecifies the radius of a window in which only the match with the greatest similarity is reported.
maxMatchesintDefines the maximum number of matches to return; or 0 to not define a limit for the number of matches.
ignoreMapbool[,]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
imageisnull.- ArgumentNullException
If
featureisnull.- ArgumentOutOfRangeException
If
similarityThresholdlies outside the interval 0.0 and 1.0.- ArgumentOutOfRangeException
If
maxMatchesis negative.- ArgumentException
If the
featureis greater in size than theimage.- ArgumentException
If the bitmap format of the
featurecannot be converted to that of theimage.
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
imageBitmapAn image.
grayscaleboolIf
trueandimageis not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).edgesboolIf
true, tries to detect object edges in the image (see DetectEdges(Bitmap)).thresholdboolIf
true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).scaleWidthdoubleIf not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).
scaleHeightdoubleIf 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
imageisnull.- ArgumentException
If the input
imageis 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
imageBitmapAn image.
grayscaleboolIf
trueandimageis not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).edgesboolIf
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 befalsewhen the method returns.useSobelboolDecides which edge detection algorithm to use if
edgesistrue. Iftrue, the Sobel edge detection algorithm is used (see DetectEdgesSobel(Bitmap)), otherwise Laplace is used (see DetectEdgesLaplace(Bitmap)).thresholdboolIf
true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).scaleWidthdoubleIf not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).
scaleHeightdoubleIf not equal to 1.0, the height of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).
offsetPointWhen 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
imageisnull.- ArgumentException
If the input
imageis 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
imageBitmapAn image.
grayscaleboolIf
trueandimageis not already a grayscale image, converts the image to a grayscale image (see ConvertRgbToGrayscaleImage(Bitmap)).edgesboolIf
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 befalsewhen the method returns.thresholdboolIf
true, a threshold (128) is applied to the image (see Threshold(Bitmap, byte)).scaleWidthdoubleIf not equal to 1.0, the width of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).
scaleHeightdoubleIf not equal to 1.0, the height of the image will be scaled using the specified factor (see Resize(Bitmap, double, double)).
offsetPointWhen 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
imageisnull.- ArgumentException
If the input
imageis 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
inputBitmapAn image.
thresholdbyteThe 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
inputisnull.- ArgumentException
If the
inputimage 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).