Read@CVL
rdf::BaseSkewEstimation Class Reference

The class estimates the skew of a document page. The methodology is based on "Skew estimation of natural images based on a salient line detector", Hyung Il Koo and Nam Ik Cho More...

#include <SkewEstimation.h>

Inheritance diagram for rdf::BaseSkewEstimation:
Collaboration diagram for rdf::BaseSkewEstimation:

Public Types

enum  EdgeDirection { HORIZONTAL = 0, VERTICAL }
 

Public Member Functions

 BaseSkewEstimation (const cv::Mat &img=cv::Mat(), const cv::Mat &mask=cv::Mat())
 Initializes a new instance of the BaseSkewEstimation class. More...
 
void setImages (const cv::Mat &img, const cv::Mat &mask=cv::Mat())
 Sets the images. More...
 
bool compute ()
 Computes the skew angle based on "Skew Estimation of natural images based on a salient line detector", Hyung Il Koo and Nam Ik Choo. More...
 
double getAngle ()
 Gets the skew angle. More...
 
QVector< QVector4D > getSelectedLines () const
 
bool isEmpty () const override
 Determines whether this instance is empty. More...
 
virtual QString toString () const override
 Summarize the method as string. Not yet implemented. More...
 
void setFixedThr (bool f)
 
QSharedPointer< BaseSkewEstimationConfigconfig () const
 
- Public Member Functions inherited from rdf::Module
 Module ()
 Default constructor Initializes a new instance of the Module class. More...
 
virtual QString name () const
 Returns the module's name. More...
 
virtual void setConfig (QSharedPointer< ModuleConfig > config)
 
QSharedPointer< ModuleConfigconfig () const
 

Protected Member Functions

cv::Mat separability (const cv::Mat &srcImg, int w, int h, const cv::Mat &mask=cv::Mat())
 Computes the separability of two neighbouring regions based on mean and variance. More...
 
cv::Mat edgeMap (const cv::Mat &separability, double thr, EdgeDirection direction=HORIZONTAL, const cv::Mat &mask=cv::Mat()) const
 Computes the edge map based on the separability More...
 
QVector< QVector3D > computeWeights (cv::Mat edgeMap, int delta, int epsilon, EdgeDirection direction=HORIZONTAL)
 Computes the PPHT, detects straight lines and refines it More...
 
double skewEst (const QVector< QVector3D > &weights, double imgDiagonal, bool &ok, double eta=0.35)
 Computes the skew based oon the detected lines More...
 
bool checkInput () const override
 Checks the input - not yet implemented. More...
 
- Protected Member Functions inherited from rdf::Module
QString debugName () const
 

Protected Attributes

cv::Mat mSrcImg
 
cv::Mat mMask
 
- Protected Attributes inherited from rdf::Module
QSharedPointer< ModuleConfigmConfig
 

Detailed Description

The class estimates the skew of a document page. The methodology is based on "Skew estimation of natural images based on a salient line detector", Hyung Il Koo and Nam Ik Cho

See also
Module

Member Enumeration Documentation

Enumerator
HORIZONTAL 
VERTICAL 

Constructor & Destructor Documentation

rdf::BaseSkewEstimation::BaseSkewEstimation ( const cv::Mat &  img = cv::Mat(),
const cv::Mat &  mask = cv::Mat() 
)

Initializes a new instance of the BaseSkewEstimation class.

Parameters
imgThe source img.
maskThe optional mask.

Member Function Documentation

bool rdf::BaseSkewEstimation::checkInput ( ) const
overrideprotectedvirtual

Checks the input - not yet implemented.

Returns

Implements rdf::Module.

bool rdf::BaseSkewEstimation::compute ( )
virtual

Computes the skew angle based on "Skew Estimation of natural images based on a salient line detector", Hyung Il Koo and Nam Ik Choo.

Returns
true if the angle could be computed

Implements rdf::Module.

QVector< QVector3D > rdf::BaseSkewEstimation::computeWeights ( cv::Mat  edgeMap,
int  delta,
int  epsilon,
EdgeDirection  direction = HORIZONTAL 
)
protected

Computes the PPHT, detects straight lines and refines it

Parameters
edgeMapThe edge map.
deltaDelta parameter: max coordinate deviation for refined lines.
epsilonEpsilon parameter: max allowed deviation from line coordinates for the weight calculation (=2).
directionThe direction (horizontal or vertical).
Returns
The line weights
QSharedPointer< BaseSkewEstimationConfig > rdf::BaseSkewEstimation::config ( ) const
cv::Mat rdf::BaseSkewEstimation::edgeMap ( const cv::Mat &  separability,
double  thr,
EdgeDirection  direction = HORIZONTAL,
const cv::Mat &  mask = cv::Mat() 
) const
protected

Computes the edge map based on the separability

Parameters
separabilityThe separability map.
thrA threshold value for edges (=0.1).
directionThe direction (horizontal or vertical).
maskThe optional mask.
Returns
The edge map.
double rdf::BaseSkewEstimation::getAngle ( )

Gets the skew angle.

Returns
The skew angle
QVector< QVector4D > rdf::BaseSkewEstimation::getSelectedLines ( ) const
bool rdf::BaseSkewEstimation::isEmpty ( ) const
overridevirtual

Determines whether this instance is empty.

Returns
true if no src image is set.

Implements rdf::Module.

cv::Mat rdf::BaseSkewEstimation::separability ( const cv::Mat &  srcImg,
int  w,
int  h,
const cv::Mat &  mask = cv::Mat() 
)
protected

Computes the separability of two neighbouring regions based on mean and variance.

Parameters
srcImgThe source img.
wThe width of the region.
hThe height of the region.
maskThe optional mask.
Returns
The separability map
void rdf::BaseSkewEstimation::setFixedThr ( bool  f)
void rdf::BaseSkewEstimation::setImages ( const cv::Mat &  img,
const cv::Mat &  mask = cv::Mat() 
)

Sets the images.

Parameters
imgThe source img.
maskThe optional mask.
double rdf::BaseSkewEstimation::skewEst ( const QVector< QVector3D > &  weights,
double  imgDiagonal,
bool &  ok,
double  eta = 0.35 
)
protected

Computes the skew based oon the detected lines

Parameters
weightsThe weights.
imgDiagonalThe img diagonal.
okOk - is set to false if only one line is detected.
etaEta - parameter to reject small lines.
Returns
QString rdf::BaseSkewEstimation::toString ( ) const
overridevirtual

Summarize the method as string. Not yet implemented.

Returns
Summary string.

Reimplemented from rdf::Module.

Member Data Documentation

cv::Mat rdf::BaseSkewEstimation::mMask
protected
cv::Mat rdf::BaseSkewEstimation::mSrcImg
protected

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