ReadFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rdf::Algorithms Class Reference

Contains basic algorithms to manipulate images. More...

#include <Algorithms.h>

Public Types

enum  MorphShape { SQUARE = 0, DISK }
 
enum  MorphBorder { BORDER_ZERO = 0, BORDER_FLIP }
 

Static Public Member Functions

static cv::Mat dilateImage (const cv::Mat &bwImg, int seSize, MorphShape shape=Algorithms::SQUARE, int borderValue=0)
 Dilates the image bwImg with a given structuring element. More...
 
static cv::Mat erodeImage (const cv::Mat &bwImg, int seSize, MorphShape shape=Algorithms::SQUARE, int borderValue=255)
 Erodes the image bwimg with a given structuring element. More...
 
static cv::Mat createStructuringElement (int seSize, int shape)
 Creates the structuring element for morphological operations. More...
 
static cv::Mat convolveSymmetric (const cv::Mat &hist, const cv::Mat &kernel)
 Convolves a histogram symmetrically. Symmetric convolution means that the convolution is flipped around at the histograms borders. This is specifically useful for orientation histograms (since 0° corresponds to 360° More...
 
static cv::Mat get1DGauss (double sigma)
 Computes a 1D Gaussian filter kernel. The kernel's size is adjusted to the standard deviation. More...
 
static cv::Mat threshOtsu (const cv::Mat &srcImg, int thType=CV_THRESH_BINARY_INV)
 Threshold an image using Otsu as threshold. More...
 
static cv::Mat convolveIntegralImage (const cv::Mat &src, const int kernelSizeX, const int kernelSizeY=0, MorphBorder norm=BORDER_ZERO)
 Convolves an integral image by means of box filters. This functions applies box filtering. It is specifically useful for the computation of image sums, mean filtering and standard deviation with big kernel sizes. More...
 
static void setBorderConst (cv::Mat &src, float val=0.0f)
 Sets the border to a constant value (1 pixel width). More...
 
static void invertImg (cv::Mat &srcImg, cv::Mat mask=cv::Mat())
 Inverts the img. More...
 
static void mulMask (cv::Mat &src, cv::Mat mask=cv::Mat())
 Applies a mask to the image. More...
 
static cv::Mat preFilterArea (const cv::Mat &img, int minArea, int maxArea=-1)
 Prefilters an binary image according to the blob size. Should be done to remove small blobs and to reduce the runtime of cvFindContours. More...
 
static cv::Mat computeHist (const cv::Mat img, const cv::Mat mask=cv::Mat())
 Computes the histogram of an image. More...
 
static double getThreshOtsu (const cv::Mat &hist, const double otsuThresh=0)
 Gets the Otsu threshold based on a certain histogram. More...
 
static double normAngleRad (double angle, double startIvl=0.0, double endIvl=2.0 *CV_PI)
 Computes the normalized angle within startIvl and endIvl. More...
 
static double angleDist (double angle1, double angle2, double maxAngle=2.0 *CV_PI)
 Computes the distance between two angles. Hence, min(angleDiff, CV_PI*2-(angleDiff)) More...
 
static cv::Mat estimateMask (const cv::Mat &src, bool preFilter=true)
 Estimates the mask. More...
 
static cv::Mat rotateImage (const cv::Mat &src, double angleRad, int interpolation=cv::INTER_CUBIC, cv::Scalar borderValue=cv::Scalar(0))
 Rotates an image according to the angle obtained. The new image bounds are minimized with respect to the angle obtained. positive angle values mean counterclockwise rotation More...
 
static double logGammaLanczos (double x)
 Computes the natural logarithm of the absolute value of the gamma function of x using the Lanczos approximation. See http ://www.rskey.org/gamma.htm More...
 
static double logGammaWindschitl (double x)
 Computes the natural logarithm of the absolute value of the gamma function of x using Windschitl method. More...
 
static double logGamma (double x)
 Computes the natural logarithm of the absolute value of the gamma function of x.When x>15 use log_gamma_windschitl(), otherwise use log_gamma_lanczos(). More...
 
static int doubleEqual (double a, double b)
 The resulting rounding error after floating point computations depend on the specific operations done.The same number computed by different algorithms could present different rounding errors.For a useful comparison, an estimation of the relative rounding error should be considered and compared to a factor times EPS.The factor should be related to the cumulated rounding error in the chain of computation.Here, as a simplification, a fixed factor is used. More...
 
static double absAngleDiff (double a, double b)
 
static double signedAngleDiff (double a, double b)
 
static QPointF calcRotationSize (double angleRad, const QPointF &srcSize)
 Calculates the image size of the rotated image. More...
 
static double min (const QVector< double > &vec)
 Returns the minimum of the vector or DBL_MAX if vec is empty. More...
 
static double max (const QVector< double > &vec)
 Returns the maximum value of vec or -DBL_MAX if vec is empty. More...
 
template<typename numFmt >
static double statMoment (const QList< numFmt > &valuesIn, double momentValue, int interpolated=1)
 Computes robust statistical moments (quantiles). More...
 
template<typename sFmt , typename mFmt >
static void mulMaskIntern (cv::Mat src, const cv::Mat mask)
 
template<typename sFmt >
static void setBorderConstIntern (cv::Mat src, sFmt val)
 

Detailed Description

Contains basic algorithms to manipulate images.

Member Enumeration Documentation

Enumerator
BORDER_ZERO 
BORDER_FLIP 
Enumerator
SQUARE 
DISK 

Member Function Documentation

double rdf::Algorithms::absAngleDiff ( double  a,
double  b 
)
static
double rdf::Algorithms::angleDist ( double  angle1,
double  angle2,
double  maxAngle = 2.0*CV_PI 
)
static

Computes the distance between two angles. Hence, min(angleDiff, CV_PI*2-(angleDiff))

Parameters
angle1The angle1.
angle2The angle2.
Returns
The angular distance.
QPointF rdf::Algorithms::calcRotationSize ( double  angleRad,
const QPointF &  srcSize 
)
static

Calculates the image size of the rotated image.

Parameters
angleRadThe angle in radians.
srcSizeSize of the source image.
Returns
The Size of the rotated image.
cv::Mat rdf::Algorithms::computeHist ( const cv::Mat  img,
const cv::Mat  mask = cv::Mat() 
)
static

Computes the histogram of an image.

Parameters
imgThe source img CV_32FC1.
maskThe mask CV_8UC1 or CV_32FC1.
Returns
The histogram of the img as cv::mat CV_32FC1.
cv::Mat rdf::Algorithms::convolveIntegralImage ( const cv::Mat &  src,
const int  kernelSizeX,
const int  kernelSizeY = 0,
MorphBorder  norm = BORDER_ZERO 
)
static

Convolves an integral image by means of box filters. This functions applies box filtering. It is specifically useful for the computation of image sums, mean filtering and standard deviation with big kernel sizes.

Parameters
srcThe integral image CV_64FC1.
kernelSizeXThe box filter's size.
kernelSizeYThe box filter's size.
normIf BORDER_ZERO an image sum is computed, if BORDER_FLIP a mean filtering is applied.
Returns
The convolved image CV_32FC1.
cv::Mat rdf::Algorithms::convolveSymmetric ( const cv::Mat &  hist,
const cv::Mat &  kernel 
)
static

Convolves a histogram symmetrically. Symmetric convolution means that the convolution is flipped around at the histograms borders. This is specifically useful for orientation histograms (since 0° corresponds to 360°

Parameters
histThe histogram CV_32FC1.
kernelThe convolution kernel CV_32FC1.
Returns
The convolved Histogram CV_32FC1.
cv::Mat rdf::Algorithms::createStructuringElement ( int  seSize,
int  shape 
)
static

Creates the structuring element for morphological operations.

Parameters
seSizeSize of the structuring element.
shapeThe shape (either Square or Disk).
Returns
A cvMat containing the structuring element (CV_8UC1).
cv::Mat rdf::Algorithms::dilateImage ( const cv::Mat &  bwImg,
int  seSize,
MorphShape  shape = Algorithms::SQUARE,
int  borderValue = 0 
)
static

Dilates the image bwImg with a given structuring element.

Parameters
bwImgThe bwImg: a grayscale image CV_8U (or CV_32F [0 1] but slower).
seSizeThe structuring element's size.
shapeThe shape (either Square or Disk).
borderValueThe border value.
Returns
An dilated image (CV_8U or CV_32F).
int rdf::Algorithms::doubleEqual ( double  a,
double  b 
)
static

The resulting rounding error after floating point computations depend on the specific operations done.The same number computed by different algorithms could present different rounding errors.For a useful comparison, an estimation of the relative rounding error should be considered and compared to a factor times EPS.The factor should be related to the cumulated rounding error in the chain of computation.Here, as a simplification, a fixed factor is used.

Parameters
aInput a
bInput b
Returns
equal if relative error <= factor x eps
cv::Mat rdf::Algorithms::erodeImage ( const cv::Mat &  bwImg,
int  seSize,
MorphShape  shape = Algorithms::SQUARE,
int  borderValue = 255 
)
static

Erodes the image bwimg with a given structuring element.

Parameters
bwImgThe bwimg: a grayscale image CV_8U (or CV_32F [0 1] but slower).
seSizeThe structuring element's size.
shapeThe shape (either Square or Disk).
borderValueThe border value.
Returns
An eroded image (CV_8U or CV_32F).
cv::Mat rdf::Algorithms::estimateMask ( const cv::Mat &  src,
bool  preFilter = true 
)
static

Estimates the mask.

Parameters
srcThe source image.
Returns
The estimated mask.
cv::Mat rdf::Algorithms::get1DGauss ( double  sigma)
static

Computes a 1D Gaussian filter kernel. The kernel's size is adjusted to the standard deviation.

Parameters
sigmaThe standard deviation of the Gaussian.
Returns
The Gaussian kernel CV_32FC1
double rdf::Algorithms::getThreshOtsu ( const cv::Mat &  hist,
const double  otsuThresh = 0 
)
static

Gets the Otsu threshold based on a certain histogram.

Parameters
histThe histogram CV_32FC1.
otsuThreshThe otsu threshold - deprecated.
Returns
The computed threshold.
void rdf::Algorithms::invertImg ( cv::Mat &  srcImg,
cv::Mat  mask = cv::Mat() 
)
static

Inverts the img.

Parameters
srcImgThe source img CV_32FC1 [0 1] or CV_8UC1.
maskThe mask.
double rdf::Algorithms::logGamma ( double  x)
static

Computes the natural logarithm of the absolute value of the gamma function of x.When x>15 use log_gamma_windschitl(), otherwise use log_gamma_lanczos().

Parameters
xThe Input x.
Returns
Natural Logarithm
double rdf::Algorithms::logGammaLanczos ( double  x)
static

Computes the natural logarithm of the absolute value of the gamma function of x using the Lanczos approximation. See http ://www.rskey.org/gamma.htm

Parameters
xInput value
Returns
Natural Algorithm
double rdf::Algorithms::logGammaWindschitl ( double  x)
static

Computes the natural logarithm of the absolute value of the gamma function of x using Windschitl method.

Parameters
xInput Value x
Returns
Natural Log using Windschitl
double rdf::Algorithms::max ( const QVector< double > &  vec)
static

Returns the maximum value of vec or -DBL_MAX if vec is empty.

Parameters
vecA vector with double values.
Returns
the maximum
double rdf::Algorithms::min ( const QVector< double > &  vec)
static

Returns the minimum of the vector or DBL_MAX if vec is empty.

Parameters
vecA vector with double values.
Returns
the minimum
void rdf::Algorithms::mulMask ( cv::Mat &  src,
cv::Mat  mask = cv::Mat() 
)
static

Applies a mask to the image.

Parameters
srcThe source img CV_8U or CV_32F.
maskThe optional mask CV_8U or CV_32F.
template<typename sFmt , typename mFmt >
static void rdf::Algorithms::mulMaskIntern ( cv::Mat  src,
const cv::Mat  mask 
)
inlinestatic
double rdf::Algorithms::normAngleRad ( double  angle,
double  startIvl = 0.0,
double  endIvl = 2.0*CV_PI 
)
static

Computes the normalized angle within startIvl and endIvl.

Parameters
angleThe angle in rad.
startIvlThe intervals lower bound.
endIvlThe intervals upper bound.
Returns
The angle within [startIvl endIvl].
cv::Mat rdf::Algorithms::preFilterArea ( const cv::Mat &  img,
int  minArea,
int  maxArea = -1 
)
static

Prefilters an binary image according to the blob size. Should be done to remove small blobs and to reduce the runtime of cvFindContours.

Parameters
imgThe source img CV_8UC1.
minAreaThe blob size threshold in pixel.
maxAreaThe maximum area.
Returns
A CV_8UC1 binary image with all blobs smaller than minArea removed.
cv::Mat rdf::Algorithms::rotateImage ( const cv::Mat &  src,
double  angleRad,
int  interpolation = cv::INTER_CUBIC,
cv::Scalar  borderValue = cv::Scalar(0) 
)
static

Rotates an image according to the angle obtained. The new image bounds are minimized with respect to the angle obtained. positive angle values mean counterclockwise rotation

Parameters
srcThe source image.
angleRadThe angle in RAD.
interpolationThe interpolation.
borderValueThe border value.
Returns
The rotated image.
void rdf::Algorithms::setBorderConst ( cv::Mat &  src,
float  val = 0.0f 
)
static

Sets the border to a constant value (1 pixel width).

Parameters
srcThe source image CV_32F or CV_8U.
valThe border value.
template<typename sFmt >
static void rdf::Algorithms::setBorderConstIntern ( cv::Mat  src,
sFmt  val 
)
inlinestatic
double rdf::Algorithms::signedAngleDiff ( double  a,
double  b 
)
static
template<typename numFmt >
static double rdf::Algorithms::statMoment ( const QList< numFmt > &  valuesIn,
double  momentValue,
int  interpolated = 1 
)
inlinestatic

Computes robust statistical moments (quantiles).

Parameters
valuesInThe statistical set (samples).
momentValueThe statistical moment value (0.5 = median, 0.25 and 0.75 = quartiles).
interpolatedA flag if the value should be interpolated if the length of the list is even.
Returns
The statistical moment.
cv::Mat rdf::Algorithms::threshOtsu ( const cv::Mat &  srcImg,
int  thType = CV_THRESH_BINARY_INV 
)
static

Threshold an image using Otsu as threshold.

Parameters
srcImgThe source img CV_8UC1 or CV_8UC3.
Returns
A binary image CV_8UC1

The documentation for this class was generated from the following files: