Core Optical, Inc.
Resampler GetPolarResampledChannel Method Industrial Strength, Scientific Grade
Resamples the data from a cartesian to a polar coordinate system and returns the result as a single-channel SourceData object.

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

public SourceData GetPolarResampledChannel(
	SourceData sourceData,
	int sourceChannel,
	ResamplingKernel kernel,
	double originRow,
	double originColumn,
	double minRadius,
	double maxRadius,
	double thetaStart,
	double sweepAngle,
	int newWidth,
	int newHeight
)

Parameters

sourceData
Type: PrecisionImage SourceData
A SourceData type containing the data to resample.
sourceChannel
Type: OnlineSystem Int32
An OnlineInt32 type indicating the channel containing the data to resample.
kernel
Type: PrecisionImage.Resampling ResamplingKernel
A ResamplingKernel type that indicates the kernel to use during the resampling operation.
originRow
Type: OnlineSystem Double
A OnlineDouble type indicating the zero-based row index of the transform origin.
originColumn
Type: OnlineSystem Double
A OnlineDouble type indicating the zero-based column index of the transform origin.
minRadius
Type: OnlineSystem Double
A OnlineDouble type indicating the minimum radius of the transform.
maxRadius
Type: OnlineSystem Double
A OnlineDouble type indicating the maximum radius of the transform.
thetaStart
Type: OnlineSystem Double
A OnlineDouble type indicating the initial angle of the transform.
sweepAngle
Type: OnlineSystem Double
A OnlineDouble type indicating the total sweep angle of the transform.
newWidth
Type: OnlineSystem Int32
An OnlineInt32 type indicating the width (radial sampling rate) of the output data.
newHeight
Type: OnlineSystem Int32
An OnlineInt32 type indicating the height (angular sampling rate) of the output data.

Return Value

A single-channel SourceData object contaiing the resampled data.
Exceptions

ExceptionCondition
OnlineSystem NullReferenceException Thrown when sourceData and/or kernel is null.
OnlineSystem ArgumentOutOfRangeException Thrown when sourceChannel refers to a channel that does not exist.
OnlineSystem ArgumentOutOfRangeException Thrown when newWidth and/or newHeight are less than 1, when minRadius is less than 0 or greater than maxRadius, when the magnitude of sweepAngle exceeds 360, or when thetaStart is less than 0 or greater than 360.
Remarks

This method resamples source data from a cartesian grid to a polar grid according to the specified origin and sweep angle. The generated SourceData result consists of the radial sampling aligned along the x-axis and the angular sampling aligned along the vertical axis, with thetaStart and minRadius located at the origin. The transform originRow and originColumn arguments are specified relative to the origin of the sourceData object. These arguments can be negative or positive. The geometry of the transform and the output are shown in the three examples below.

The thetaStart argument refers to the initial angle of the polar region, in degrees. This value must be between 0 and 360 or an exception will result. The value indicates a counter-clockwise rotation about the specified origin. The sweepAngle value specifies the included angle measured from thetaStart, with a positive value indicating a counter-clockwise sweep and a negative value indicating a clockwise sweep from thetaStart. The magnitude of this value must be between 0 and 360 or an exception will result.

The minRadius and maxRadius values refer to the start and stop distances, respectively, from the transform origin. The minRadius value must be positive and the maxRadius value must be greater than minRadius or an exception will result.

The newWidth and newHeight refer to the output size of the generated SourceData result. These are the radial and angular sampling rates, respectively.

The EdgeHandling property for this operation will always default to ZeroedEdges for this operation.

Examples

The first example illustrates the resampling of cartesian-grid data to a polar-coordinate grid whose region-of-interest consists of an inscribed circle.

using PrecisionImage;
using PrecisionImage.Resampling;


// Load the image and display: 
Uri imageUri                   = new Uri("Lena256.tif", UriKind.Relative);
TiffBitmapDecoder imageDecoder = new TiffBitmapDecoder(imageUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource sourceImage       = imageDecoder.Frames[0];
image1.Source                  = sourceImage;

// Load the image into the SourceData object:
sourceData = new SourceData(sourceImage, GammaEncoding.None);

// Compute the origin row/column coordinates. Use the center of the  
// data as the origin of the trasnform. The origin coordinates 
// are based on the source data indices: 
Int32 LastRowIndex       = sourceData.Rows - 1;
Int32 LastColumnIndex    = sourceData.Columns - 1;
Double OriginColumnIndex = (Double)LastColumnIndex * 0.5;
Double OriginRowIndex    = (Double)LastRowIndex * 0.5;

// Set the minimum radius as 0 and the maximum radius as the 
// half-dimension of the source data: 
Double MinRadius = 0;
Double MaxRadius = (Double)LastColumnIndex * 0.5;

// Set the start angle of the transform as 0 and the sweep 
// angle as a full 360 degrees (positive value = counter-clockwise sweep) 
Double ThetaStart = 0;
Double SweepAngle = 360;

// Set the sampling rates for the resampling operation. Use the original data width 
// as the radial sampling rate, and twice the source data height as the angular 
// sampling rate to avoid aliasing and reconstruction artifacts later: 
Int32 outputWidth  = sourceData.Columns;
Int32 outputHeight = sourceData.Rows * 2;

// Instantiate a new Resampler to perform the resampling: 
Resampler resampler = new Resampler();

// Resample the data in channel 0 and retrieve the result: 
SourceData polarResampledData = resampler.GetPolarResampledChannel(sourceData, 0, new BicubicKernel(), OriginRowIndex, OriginColumnIndex,
                                                                   MinRadius, MaxRadius, ThetaStart, SweepAngle, outputWidth, outputHeight);

// Display the resampled data. Use an OutputWindowing object so the values aren't rescaled when an image is generated:
image2.Source = polarResampledData.GetChannelImage(GrayBitDepth.EightBit, 0, GammaEncoding.None, new PrecisionImage.Visualization.OutputWindowing(0, 1));

// Resample the polar-transformed data back to a catesian grid with the same dimensions as the original source data: 
SourceData cartesianResampledData = resampler.GetPolarToCartesianResampledChannel(polarResampledData, 0, new BicubicKernel(), OriginRowIndex, OriginColumnIndex,
                                                                                  MinRadius, MaxRadius, ThetaStart, SweepAngle, outputWidth, outputHeight / 2);

// Display the result. Use an OutputWindowing object so the values aren't rescaled when an image is generated:
image3.Source = cartesianResampledData.GetChannelImage(GrayBitDepth.EightBit, 0, GammaEncoding.None, new PrecisionImage.Visualization.OutputWindowing(0, 1));

The following images illustrates the transform geometry and the output images:

The second example is similar to the first but the polar region-of-interest contains the entire image. This simply involves a change to the above example to enlarge the maximum radius value:

// Set the minimum radius as 0 and the maximum radius as the 
// diagonal-dimension of the source data: 
Double MinRadius = 0;
Double Length1   = (Double)LastColumnIndex * 0.5;
Double Length2   = (Double)LastRowIndex * 0.5;
Double MaxRadius = Math.Sqrt(Length1 * Length1 + Length2 * Length2);

The following images illustrates the transform geometry and the output images:

The final example shows the use of transform geometry that involves an origin located off the data.

// Set the origin coordinates to a point off the source data: 
Double OriginRowIndex    = -50;
Int32 LastColumnIndex    = sourceData.Columns - 1;
Double OriginColumnIndex = (Double)LastColumnIndex * 0.5;

// Set the minimum radius from the origin as 100 and the maximum radius 
// from the origin as 275: 
Double MinRadius = 100;
Double MaxRadius = 275;

// Set the start angle of the transform as 245 degrees and a sweep  
// angle of 50 degrees counter-clockwise: 
Double ThetaStart   = 245;
Double SweepAngle   = 50;

// Set the sampling rates for the resampling operation: 
Int32 outputWidth  = sourceData.Columns;
Int32 outputHeight = sourceData.Rows;

// Instantiate a new Resampler to perform the resampling: 
Resampler resampler = new Resampler();

// Resample the data in channel 0 and retrieve the result: 
SourceData polarResampledData = resampler.GetPolarResampledChannel(sourceData, 0, new BicubicKernel(), OriginRowIndex, OriginColumnIndex,
                                                                   MinRadius, MaxRadius, ThetaStart, SweepAngle, outputWidth, outputHeight);

// Display the resampled data. Use an OutputWindowing object so the values aren't rescaled when an image is generated:
image2.Source = polarResampledData.GetChannelImage(GrayBitDepth.EightBit, 0, GammaEncoding.None, new PrecisionImage.Visualization.OutputWindowing(0, 1));

// Resample the polar-transformed data back to a catesian grid. Use the same sampling rate as the original data: 
SourceData cartesianResampledData = processor.GetPolarToCartesianResampledChannel(polarResampledData, 0, new BicubicKernel(), OriginRowIndex, OriginColumnIndex,
                                                                                  MinRadius, MaxRadius, ThetaStart, SweepAngle, outputWidth, outputHeight);

// Display the result. Use an OutputWindowing object so the values aren't rescaled when an image is generated:
image3.Source = cartesianResampledData.GetChannelImage(GrayBitDepth.EightBit, 0, GammaEncoding.None, new PrecisionImage.Visualization.OutputWindowing(0, 1));

The following images illustrates the transform geometry and the output images:

See Also