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

Image filtering with averaging, mean or median

Functions

template<typename imageTout , typename imageTin >
int mx::improc::meanSmooth (imageTout &imOut, const imageTin &imIn, int meanFullWidth, bool rejectMinMax=false)
 Smooth an image using the mean in a rectangular box, optionally rejecting the highest and lowest values. More...
 
template<typename imageTout , typename imageTin >
int mx::improc::meanSmooth (imageTout &imOut, int &xMax, int &yMax, typename imageTout::Scalar &pMax, const imageTin &imIn, int meanFullWidth, bool rejectMinMax=false)
 Smooth an image using the mean in a rectangular box, optionally rejecting the highest and lowest values. Determines the location and value of the highest pixel. More...
 
template<typename imageTout , typename imageTin >
int mx::improc::medianSmooth (imageTout &imOut, int &xMax, int &yMax, typename imageTout::Scalar &pMax, const imageTin &imIn, int medianFullWidth)
 Smooth an image using the median in a rectangular box. Also Determines the location and value of the highest pixel in the smoothed image. More...
 
template<typename imageTout , typename imageTin >
int mx::improc::medianSmooth (imageTout &imOut, const imageTin &imIn, int medianFullWidth)
 Smooth an image using the median in a rectangular box.
More...
 

Function Documentation

◆ meanSmooth() [1/2]

template<typename imageTout , typename imageTin >
int mx::improc::meanSmooth ( imageTout &  imOut,
const imageTin &  imIn,
int  meanFullWidth,
bool  rejectMinMax = false 
)

Smooth an image using the mean in a rectangular box, optionally rejecting the highest and lowest values.

Calculates the mean value in a rectangular box of imIn, of size meanFullSidth X meanFullWidth and stores it in the corresonding center pixel of imOut. Does not smooth the 0.5*meanFullwidth rows and columns of the input image, and the values of these pixels are not changed in imOut (i.e. you should 0 them before the call).

imOut is not re-allocated.

If rejectMinMax is true then the minimum and maximum value in the box are not included in the mean. Rejection makes the algorithm somewhat slower, depending on box width.

Template Parameters
imageToutis an eigen-like image array
imageTinis an eigen-like image array
Returns
0 on success
-1 on error.
Parameters
[out]imOutthe smoothed image. Not re-allocated, and the edge pixels are not modified.
[in]imInthe image to smooth
[in]meanFullWidththe full-width of the smoothing box
[in]rejectMinMaxwhether or not to reject the min and max value.

Definition at line 485 of file imageFilters.hpp.

◆ meanSmooth() [2/2]

template<typename imageTout , typename imageTin >
int mx::improc::meanSmooth ( imageTout &  imOut,
int &  xMax,
int &  yMax,
typename imageTout::Scalar &  pMax,
const imageTin &  imIn,
int  meanFullWidth,
bool  rejectMinMax = false 
)

Smooth an image using the mean in a rectangular box, optionally rejecting the highest and lowest values. Determines the location and value of the highest pixel.

Calculates the mean value in a rectangular box of imIn, of size meanFullSidth X meanFullWidth and stores it in the corresonding center pixel of imOut. Does not smooth the 0.5*meanFullwidth rows and columns of the input image, and the values of these pixels are not changed in imOut (i.e. you should 0 them before the call).

imOut is not re-allocated.

If rejectMinMax is true then the minimum and maximum value in the box are not included in the mean. Rejection makes the somewhat slower, depending on box width.

This version also determines the location and value of the maximum pixel. This adds some overhead, maybe on the order of 10% slower than without.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Template Parameters
imageToutis an eigen-like image array
imageTinis an eigen-like image array
Returns
0 on success
-1 on error.
Parameters
[out]imOutthe smoothed image. Not re-allocated, and the edge pixels are not modified.
[out]xMaxthe x-locatioin of the max pixel
[out]yMaxthe y-locatioin of the max pixel
[out]pMaxthe value of the max pixel
[in]imInthe image to smooth
[in]meanFullWidththe full-width of the smoothing box
[in]rejectMinMaxwhether or not to reject the min and max value.

Definition at line 566 of file imageFilters.hpp.

◆ medianSmooth() [1/2]

template<typename imageTout , typename imageTin >
int mx::improc::medianSmooth ( imageTout &  imOut,
const imageTin &  imIn,
int  medianFullWidth 
)

Smooth an image using the median in a rectangular box.

Calculates the median value in a rectangular box of imIn, of size medianFullSidth X medianFullWidth and stores it in the corresponding center pixel of imOut. Does not smooth the outer 0.5*medianFullwidth rows and columns of the input image, and the values of these pixels are not changed in imOut (i.e. you should 0 them before the call).

imOut is not re-allocated.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Template Parameters
imageToutis an eigen-like image array
imageTinis an eigen-like image array
Returns
0 on success
-1 on error.
Parameters
[out]imOutthe smoothed image. Not re-allocated, and the edge pixels are not modified.
[in]imInthe image to smooth
[in]medianFullWidththe full-width of the smoothing box

Definition at line 722 of file imageFilters.hpp.

◆ medianSmooth() [2/2]

template<typename imageTout , typename imageTin >
int mx::improc::medianSmooth ( imageTout &  imOut,
int &  xMax,
int &  yMax,
typename imageTout::Scalar &  pMax,
const imageTin &  imIn,
int  medianFullWidth 
)

Smooth an image using the median in a rectangular box. Also Determines the location and value of the highest pixel in the smoothed image.

Calculates the median value in a rectangular box of imIn, of size medianFullSidth X medianFullWidth and stores it in the corresonding center pixel of imOut. Does not smooth the 0.5*medianFullwidth rows and columns of the input image, and the values of these pixels are not changed in imOut (i.e. you should 0 them before the call).

imOut is not re-allocated.

Also determines the location and value of the maximum pixel. This is a negligble overhead compared to the median operation.

Template Parameters
imageToutis an eigen-like image array
imageTinis an eigen-like image array
Returns
0 on success
-1 on error.
Parameters
[out]imOutthe smoothed image. Not re-allocated, and the edge pixels are not modified.
[out]xMaxthe x-locatioin of the max pixel
[out]yMaxthe y-locatioin of the max pixel
[out]pMaxthe value of the max pixel
[in]imInthe image to smooth
[in]medianFullWidththe full-width of the smoothing box

Definition at line 661 of file imageFilters.hpp.

References mx::math::vectorMedianInPlace().

Referenced by mx::improc::HCIobservation< _realT >::preProcess().