IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Band-pass frequency filtering 2d

Filters an image in Fourier domain by selecting a frequency range. More...

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::frequencyFiltering2dImg (const image::ImageConstPtr &pInImg, const attr::eFrequencyBandPassFilterType &frequencyBandPassFilterType, const ipReal64 cutoffFrequency, const ipReal32 inStdDev)
 wrapper function for Filters an image in Fourier domain by selecting a frequency range More...
 
IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::frequencyFiltering2dImg (const image::ImageConstPtr &pInImg, const attr::eFrequencyBandPassFilterType &frequencyBandPassFilterType, const ipReal64 cutoffFrequency, const ipReal32 inStdDev, const ipReal32 theta, const ipReal64 thetaRange)
 wrapper function for Filters an image in Fourier domain by selecting a frequency range More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::frequencyFiltering2dImg (const image::ImageConstPtr &pInImg, const attr::eFrequencyBandPassFilterType &frequencyBandPassFilterType, const ipReal64 cutoffFrequency, const ipReal32 inStdDev, image::ImagePtr &pOutImg)
 wrapper function for Filters an image in Fourier domain by selecting a frequency range More...
 
IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::frequencyFiltering2dImg (const image::ImageConstPtr &pInImg, const attr::eFrequencyBandPassFilterType &frequencyBandPassFilterType, const ipReal64 cutoffFrequency, const ipReal32 inStdDev, const ipReal32 theta, const ipReal64 thetaRange, image::ImagePtr &pOutImg)
 wrapper function for Filters an image in Fourier domain by selecting a frequency range More...
 

Detailed Description

Filters an image in Fourier domain by selecting a frequency range.

This algorithm applies a band-pass filter to the input image in the frequency domain. Such an approach is very powerful since a convolution in the spatial domain becomes a pixelwise multiplication in the Fourier domain. Hence, it is computationnally faster than a spatial filtering, in particular for large kernel sizes. Moreover, it is possible to design a filter in order to fit a determined frequency range.

The steps of the algorithm are:

The figure below illustrates how the band-pass filtering in frequency domain works (the signal spectrum is normalized for convenience).

bandpassFiltering_example1d.png

The first row displays a noisy signal, which normalized frequency equals 0.2. In the second row are shown the signal spectrum and a window filter centered around 0.2 (the signal frequency). Because the signal spectrum is symmetric, so is the filter. Finally, the third row plots the reconstructed signal: the noise has been deleted.

However, a step filter as illustrated in the figure above will produce ringing artefacts (https://en.wikipedia.org/wiki/Ringing_artifacts), as shown in the figure below:

bandpassFiltering_ring2d.png

In this figure, the initial image is a square (top-left image), its spectrum modulus (bottom-left image), the filter (bottom-right image) and the resulting filtered image, presenting ringing artefacts (top-right image).

For this reason, the algorithm does not use window filters and two other band-pass filters instead:

where $ f = \sqrt{u^2+v^2}$, $u, v$ being respectively the frequencies along the image axes.

Both filters need only two parameters: a cutoff frequency cutoffFrequency and a standard deviation stdDev, which make them easily configurable. However, the logGabor bandwidth changes when varying the cutoff frequency, even if the standard deviation is constant. The figure below shows how the logGabor function varies when the cut off frequency increases and the standard deviation is constant and set to 0.25.

bandpassFiltering_logGabor1d.png

In some images, it may be interesting to isolate a texture with a specific orientation. For this reason, the algorithm allows to specify an orientation theta and a range thetaRange which will mask the filtered spectrum and keep only the information in the desired direction range, both in degrees.

Note
We must have 0° $\leq$ theta $\leq$ 180° and 0° < thetaRange $\leq$ 180°. If not, the default values are theta = 0° and thetaRange = 180° (i.e. select all the orientations).

The figure below illustrates an image with three shapes in the first column. The square and the circle textures have the same frequency (0.04) but different orientations whereas the triangle texture frequency is different (0.08). The second columns shows the logGabor filter configured to select the square and circle textures (top) and its masked oriented version (bottom). Finally, the third column displays the resulting filtered images. We can see that both textures are selected in the non oriented filter whereas only the texture of the circle remains after applying the oriented filter.

bandpassFiltering_textures.png
Note
There is a subtlety between orientation of the texture and the spectrum. A horizontal spreading sinusoid yields vertical strips, as shown in the top-left figure below. That is why the spectrum is oriented horizontally. The filter orientation is hence 0° and not 90°. In the same way, the sinusoid and its spectrum in the second row have an orientation of 30° (clockwise) but the texture apprears like 60° (counter-clockwise) oriented strips.
bandpassFiltering_orientationSpectrum.png

Attributes description

Attribute description for algorithm :

Name ToolTip Default Initializer
ipsdk::imaproc::attr::InImg [Input] image for processing operation X
ipsdk::imaproc::attr::InFrequencyBandPassFilterType [Input] Indicates the band-pass filter to apply on the input image X
ipsdk::imaproc::attr::InCutoffFrequency [Input] Cutoff normalizes frequency for band-pass filtering in Fourier space (must belong to [-0.5, 0.5[) X
ipsdk::imaproc::attr::InStdDev [Input] standard deviation used for operation along all axis X
ipsdk::imaproc::attr::InOptTheta [Input Optional] 2d orientation for processing operation X
ipsdk::imaproc::attr::InOptRangeTheta [Input Optional] Orientation range in degrees X
ipsdk::imaproc::attr::OutWk1RealImg [Output] Temporary working image for algorithm duplicateInOut (_pOutWk1RealImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Real32)
ipsdk::imaproc::attr::OutWk2RealImg [Output] Temporary working image for algorithm duplicateInOut (_pOutWk2RealImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Real32)
ipsdk::imaproc::attr::OutWk3RealImg [Output] Temporary working image for algorithm duplicateInOut (_pOutWk3RealImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Real32)
ipsdk::imaproc::attr::OutWk4RealImg [Output] Temporary working image for algorithm duplicateInOut (_pOutWk4RealImg, _pInImg, ipsdk::image::eImageBufferType::eIBT_Real32)
ipsdk::imaproc::attr::OutImg [Output] image for processing operation duplicateInOut (_pOutImg, _pInImg)

Global Rule description

Global rule description for algorithm :
ipsdk::imaproc::matchSizeAndType (_pInImg,_pOutImg) && 
ipsdk::imaproc::matchSizeAndType (_pOutWk1RealImg,_pOutWk2RealImg) && 
ipsdk::imaproc::matchSizeAndType (_pOutWk2RealImg,_pOutWk3RealImg) && 
ipsdk::imaproc::matchSizeAndType (_pOutWk3RealImg,_pOutWk4RealImg) && 
ipsdk::imaproc::matchSize (_pInImg,_pOutWk1RealImg)

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLFiltering as filter

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# define the parameters
f0 = 0.2
sigma = 0.18
theta = 45
thetaRange = 30
# Gaussian Band-pass filtering
outGaussianImg = filter.frequencyFiltering2dImg(inImg, PyIPSDK.eFrequencyBandPassFilterType.eFBPFT_Gaussian, f0, sigma, theta, thetaRange)
# LogGabor Band-pass filtering
outLogGaborImg = filter.frequencyFiltering2dImg(inImg, PyIPSDK.eFrequencyBandPassFilterType.eFBPFT_LogGabor, f0, sigma, theta, thetaRange)

Example of C++ code :

Example informations

Associated library

IPSDKIPLFiltering

Header file

Code Example

// Gaussian frequency filtering
// -----------------------------------
ImagePtr pGaussOutImg = frequencyFiltering2dImg(pInImg, eFrequencyBandPassFilterType::eFBPFT_Gaussian, f0, sigma, theta, thetaRange);
// LogGabor frequency filtering
// -----------------------------------
ImagePtr pLogGaborOutImg = frequencyFiltering2dImg(pInImg, eFrequencyBandPassFilterType::eFBPFT_LogGabor, f0, sigma, theta, thetaRange);
See also
FrequencyFiltering2dImgLvl1
FrequencyFiltering2dImgLvl2

Function Documentation

◆ frequencyFiltering2dImg() [1/4]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::frequencyFiltering2dImg ( const image::ImageConstPtr pInImg,
const attr::eFrequencyBandPassFilterType frequencyBandPassFilterType,
const ipReal64  cutoffFrequency,
const ipReal32  inStdDev 
)

wrapper function for Filters an image in Fourier domain by selecting a frequency range

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ frequencyFiltering2dImg() [2/4]

IPSDKIPLFILTERING_API image::ImagePtr ipsdk::imaproc::filter::frequencyFiltering2dImg ( const image::ImageConstPtr pInImg,
const attr::eFrequencyBandPassFilterType frequencyBandPassFilterType,
const ipReal64  cutoffFrequency,
const ipReal32  inStdDev,
const ipReal32  theta,
const ipReal64  thetaRange 
)

wrapper function for Filters an image in Fourier domain by selecting a frequency range

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ frequencyFiltering2dImg() [3/4]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::frequencyFiltering2dImg ( const image::ImageConstPtr pInImg,
const attr::eFrequencyBandPassFilterType frequencyBandPassFilterType,
const ipReal64  cutoffFrequency,
const ipReal32  inStdDev,
image::ImagePtr pOutImg 
)

wrapper function for Filters an image in Fourier domain by selecting a frequency range

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure

◆ frequencyFiltering2dImg() [4/4]

IPSDKIPLFILTERING_API void ipsdk::imaproc::filter::frequencyFiltering2dImg ( const image::ImageConstPtr pInImg,
const attr::eFrequencyBandPassFilterType frequencyBandPassFilterType,
const ipReal64  cutoffFrequency,
const ipReal32  inStdDev,
const ipReal32  theta,
const ipReal64  thetaRange,
image::ImagePtr pOutImg 
)

wrapper function for Filters an image in Fourier domain by selecting a frequency range

Exceptions
ipsdk::processor::IPSDKBaseProcessingExceptionon failure