Core Optical, Inc.
XYGradientEdgeDetector GetEdgeMagnitudeImageArray Method Industrial Strength, Scientific Grade
Returns an OnlineArray object containing the pixel values of the gradient magnitude image for the source data.

Namespace: PrecisionImage.FeatureProcessing
Assembly: PrecisionImage (in PrecisionImage.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax

public Array GetEdgeMagnitudeImageArray(
	SourceData sourceData,
	int channel,
	GrayBitDepth grayBitDepth = GrayBitDepth.EightBit,
	Int32Rect regionOfInterest = null,
	GammaEncoding gammaEncoding = GammaEncoding.None
)

Parameters

sourceData
Type: PrecisionImage SourceData
A SourceData type containing the image data.
channel
Type: OnlineSystem Int32
An OnlineInt32 type indicating the data channel to process.
grayBitDepth (Optional)
Type: PrecisionImage GrayBitDepth
A GrayBitDepth enumerator indicating the bit-depth of the returned grayscal BitmapSource image.
regionOfInterest (Optional)
Type: OnlineSystem.Windows Int32Rect
An OnlineInt32Rect type indicating the region of interest. Coordinates are zero-index based. This parameter is optional and defaults to the entire image.
gammaEncoding (Optional)
Type: PrecisionImage GammaEncoding
A GammaEncoding enumeration specifying whether the otuput is gamma encoded or not. Default is GammaEncoding.None.

Return Value

An OnlineArray object containing the pixel values of the gradient image.
Exceptions

ExceptionCondition
OnlineSystem ArgumentNullException Thrown when sourceData is null.
OnlineSystem ArgumentOutOfRangeException Thrown when regionOfInterest is not completely contained within the source data dimensions.
OnlineSystem ArgumentOutOfRangeException Thron when channel specifies a data channel that does not exist in sourceData.
Remarks

Use this method in order to retrieve an OnlineArray containing the pixel values of the gradient magnitude image of the source data. Cast the array to whatever type was specified (Byte, UShort, Single) depending on the grayBitDepth specified to access the individual pixel values. The length of the array (in array elements) is equal to the product of the region of interest width and height. If no region of interest was specified, the length of the returned array is equal to the product of the source data rows and columns.
Examples

The following example retrieves an array of bytes containing pixel values representing the gradient magnitude of the source data:

using System.PrecisionImage;
using System.FeatureProcessing;

// Read the source (16-bit) image from disk and load into a SourceData object: 
Uri imageUri                   = new Uri("HorseStatueXray.tif", UriKind.Relative);
TiffBitmapDecoder imageDecoder = new TiffBitmapDecoder(imageUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource SourceImage       = imageDecoder.Frames[0];
SourceData imageData           = new SourceData(SourceImage, GammaEncoding.None);

// Display original image in Image component:
image1.Source = SourceImage;

// Instantiate a SobelEdgeDetector object to process the data: 
SobelEdgeDetector edgeDetector = new SobelEdgeDetector();

// Retrieve the pixel array of the processed result. Even though the source is 16-bit, just retrieve  
// 8-bit pixels (the default) for display purposes. Don't gamma encode: 
Byte[] pixels = (Byte[])edgeDetector.GetEdgeMagnitudeImageArray(imageData, 0, gammaEncoding: GammaEncoding.None);

See Also