Core Optical, Inc.
DirectionalFrequencyFilter ClassIndustrial Strength, Scientific Grade
The abstract base class for the non-isotropic (directional) spatial frequency band-pass / band-stop filters.
Inheritance Hierarchy

OnlineSystem Object
  PrecisionImage.FrequencyDomainProcessing DirectionalFrequencyFilter
    PrecisionImage.FrequencyDomainProcessing DirectionalBandPassFilter
    PrecisionImage.FrequencyDomainProcessing DirectionalBandStopFilter

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

public abstract class DirectionalFrequencyFilter
Remarks

The DirectionalFrequencyFilter is a more versatile version of the IsotropicFrequencyFilter. It is used for selectively attenuating (or passing) spatial frequency components at specific angles and frequencies. The DirectionalFrequencyFilter class is abstract and cannot be inherited from in 3rd party applications. It is used as the base class for the DirectionalBandPassFilter and DirectionalBandStopFilter classes and defines their common behavior and functionality.

The DirectionalFrequencyFilter class does not expose a HardwareAccelerationDevice property as it only supports single and multithread CPU processing modes.

Both directional frequency filters make use of the same geometry (specified during object instantiation and altered later if needed by using their properties). The filter specification requires a central frequency for centering the filter zone. This frequency is specified in normalized Nyquist frequency terms. In addition to the central frequency there are two properties (NormalizedLength and NormalizedHeight) that specify the height and width of the filter zone. Both are specified by Nyquist normalized frequency span values. The ThetaDegrees property specifies a rotational angle (in degrees) about the spectrum DC-term center. Finally, the WindowFunction is used to alter the attenuation function applied to the filter zone. This can be either an ideal attenuation by specifying a ZonalWindowFunction for this property, or any of the smoothly tapering window functions such as KaiserWindowFunction.

following is an illustration of the filter geometry parameters as they relate to the image spectrum:

The directional frequency filters expose the (GetFilterImage(Int32, GrayBitDepth, GammaEncoding) method which can be used to visualize the filter. This is useful for filter design. For example, to visualize a band-pass filter centered at the DC term, with a NormalizedLength equal to 1.0f and a NormalizedHeight equal to 0.1f, a 0-degree rotation so that the filter zone is aligned with the horizontal axis of the spectrum, and smoothly tapered using a Kaiser window, one would do the following:

using PrecisionImage;
using PrecisionImage.FrequencyDomainProcessing;

// Instantiate the window function: 
WindowFunction window = new KaiserWindowFunction();
window.Style = FunctionStyle.Squared;

// Instantiate the directional filter: 
Single FrequencyCenter           = 0.0f;
Single FrequencySpanLength       = 1.0f;
Single FrequencySpanHeight       = 0.1f;
Single Rotation                  = 0.0f;
DirectionalBandPassFilter filter = new DirectionalBandPassFilter(FrequencyCenter, FrequencySpanLength, FrequencySpanHeight, Rotation, window);

// Visualize: 
Int32 ImageSize = 512; // pixels (square image).
image1.Source   = filter.GetFilterImage(ImageSize, PixelFormats.Gray8, GammaEncoding.sRGB);
The above generates an image similar to the following:

Alternatively, for frequencies at arbitrary angles other than 0 or 90 degrees and centered at frequencies other than 0.0:

using PrecisionImage;
using PrecisionImage.FrequencyDomainProcessing;

// Instantiate the window function: 
WindowFunction window = new KaiserWindowFunction();
window.Style = FunctionStyle.Elliptical

// Instantiate the directional filter: 
Single FrequencyCenter           = 0.5f;
Single FrequencySpanLength       = 0.25f;
Single FrequencySpanHeight       = 0.25f;
Single Rotation                  = 45.0f;
DirectionalBandPassFilter filter = new DirectionalBandPassFilter(FrequencyCenter, FrequencySpanLength, FrequencySpanHeight, Rotation, window);

// Visualize: 
Int32 ImageSize = 512; // pixels (square image).
image1.Source   = filter.GetFilterImage(ImageSize, PixelFormats.Gray8, GammaEncoding.sRGB);
The above generates an image similar to the following:

Directional frequency filters are very useful for removing noise that is known to be correlated with particular frequencies and/or directions. Often, the noise can be removed or minimized by targetting a narrow cluster of frequencies with a directional band-stop filter. This is illustrated in the following example, where a TEM micrograph can be seen to exhibit a subtle sinusoidal noise pattern (perhaps due to sample preparation or sample charging). By inspection the noise has a wavelength of approximately 40 pixels. With an image of 1024 pixel dimensions this correspponds to a frequency of 25 Hz. The orientation of the noise is approximately 20 degrees from horizontal. To filter this noise from the image using a directional filter, do the following:

using PrecisionImage;
using PrecisionImage.FrequencyDomainProcessing;

// Load 8-bit grayscale image: 
Uri imageUri = new Uri("NucleiTEM.tif", UriKind.Relative);
TiffBitmapDecoder imageDecoder = new TiffBitmapDecoder(imageUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
SourceImage = imageDecoder.Frames[0];

// Load linear image data:
Sourcedata imageData = new SourceData(SourceImage, GammaEncoding.sRGB);

// Display image prior to filtering:
image1.Source = imageData.GetChannelImage(PixelFormats.Gray8, GammaEncoding.sRGB, 0);

// Compute filter parameters: 
Single NyquistFrequency    = (Single)imageData.Columns * 0.5f;            // Max frequency in Hz. 
Single NoiseWavelength     = 40.0f;                                       // (Pixels), by observation. 
Single NoiseFrequency      = (Single)imageData.Columns / NoiseWavelength; // Compute noise frequency. 
Single CentralFrequency    = NoiseFrequency / NyquistFrequency;           // Compute Nyquist-normalized noise frequency. 
Single FrequencySpanLength = 0.08f;                                       // Estimate a region around the central frequency to attenuate. 
Single FrequencySpanHeight = 0.009f;                                      // Estimate a region around the central frequency to attenuate. 
Single Rotation            = 90.0f + 20.0f;                               // Angle (in degrees) normal to the noise orientation. 

// Instantiate the filter: 
DirectionalBandStopFilter filter = new DirectionalBandStopFilter(CentralFrequency, FrequencySpanlength, FrequencySpanHeight, Rotation, new ZonalWindowFunction());

// Apply filter in-place:
filter.ApplyFilter(imageData, 0);

// Display filtered image:
image2.Source = imageData.GetChannelImage(PixelFormats.Gray8, GammaEncoding.sRGB, 0);
Output:

See Also