mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches

Image filtering with a kernel.

The filter function use a kernel that specifies how to filter the image. Filter kernels, usually denoted as type kernelT below, must have the following interface:

struct filterKernel
{
typedef <eigen-like type> arrayT; // arrayT must have an eigen-like interface
typedef <type> arithT; // the type used for arithmetic, normally `typename arrayT::Scalar`
typedef <verbosity-type> verboseT; // the mxlib verbosity for error reports
//The maxWidth function returns the maximum possible full-width (in either direction) of the kernel
// Called only once for each call to the filter function
int maxWidth() const
{
//returns the maximum half-width given the configuration
}
//The setKernel function is called for each pixel.
void setKernel( arithT x, // the pixel x-position relative to the image center (not the pixel index)
arithT y, // the pixel y-position relative to the image center (not the pixel index)
arrayT & kernel // the array to be resized and populated
) const
{
//This must resize and populate the passed in kernel array each time
//so that it is re-entrant.
//Note: On output kernel array should be normalized so that sum() = 1.0
//Note: the width and height of the kernel array should always be odd
}
};

Additionally kernelT must be copyable.

/ / Symetric Gaussian smoothing kernel /**

Classes

struct  mx::improc::azBoxKernel< _arrayT, _kernW, _verboseT >
 Azimuthally variable boxcar kernel. More...
 

Functions

template<typename imageOutT , typename imageInT , typename kernelT >
error_t mx::improc::filterImage (imageOutT &fim, imageInT im, const kernelT &kernel, int maxr=0)
 Filter an image with a mean kernel.
 
template<typename imageOutT , typename imageInT , typename kernelT >
void mx::improc::medianFilterImage (imageOutT &fim, imageInT im, const kernelT &kernel, int maxr=0, int maxrproc=1)
 Filter an image with a median kernel.
 

Function Documentation

◆ filterImage()

template<typename imageOutT , typename imageInT , typename kernelT >
error_t mx::improc::filterImage ( imageOutT &  fim,
imageInT  im,
const kernelT &  kernel,
int  maxr = 0 
)

Filter an image with a mean kernel.

Applies the kernel to each pixel in the image and sums, storing the filtered result in the output image.

Template Parameters
imageOutTthe type of the output image (must have an Eigen-like interface)
imageInTthe type of the input image (must have an Eigen-like interface)
kernelTis the kernel type (see above for requirements)
Parameters
[out]fimContains the filtered image, will be resized
[in]imthe image to be filtered
[in]kernela fully configured kernel object
[in]maxr[opt] the maximum radius from the image center to apply the kernel. pixels outside this radius are set to 0.

Definition at line 395 of file imageFilters.hpp.

References mx::noerror.

Referenced by mx::AO::applyPupil2Basis(), and mx::improc::imCenterCircleSym< realT >::center().

◆ medianFilterImage()

template<typename imageOutT , typename imageInT , typename kernelT >
void mx::improc::medianFilterImage ( imageOutT &  fim,
imageInT  im,
const kernelT &  kernel,
int  maxr = 0,
int  maxrproc = 1 
)

Filter an image with a median kernel.

Calculates the median of all pixels corresponding to non-zero pixels in the kernel, storing the filtered result in the output image.

Template Parameters
imageOutTthe type of the output image (must have an Eigen-like interface)
imageInTthe type of the input image (must have an Eigen-like interface)
kernelTis the kernel type (see above for requirements)
Parameters
[out]fimContains the filtered image, will be resized
[in]imthe image to be filtered
[in]kernela fully configured kernel object
[in]maxr[opt] the maximum radius from the image center to apply the kernel. Psixels outside this radius are set to 0.

Definition at line 540 of file imageFilters.hpp.

References mx::math::vectorMedianInPlace().