Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Member Functions | Private Attributes
icl::cv::HoughLineDetector Class Reference

#include <HoughLineDetector.h>

Inheritance diagram for icl::cv::HoughLineDetector:
icl::utils::Uncopyable

List of all members.

Public Member Functions

 HoughLineDetector (float dRho, float dR, const utils::Range32f rRange, float rInhibitionRange, float rhoInhibitionRange, bool gaussianInhibition=true, bool blurHoughSpace=true, bool dilateEntries=true, bool blurredSampling=false)
 Create a new HoughLineDetectorInstance.
void add (const utils::Point &p)
 adds a new point
void add (const std::vector< utils::Point > &ps)
 adds new points
void add (const utils::Point32f &p)
 adds a new point
void add (const std::vector< utils::Point32f > &ps)
 adds new points
template<class T >
void add (const math::FixedColVector< T, 2 > &p)
 adds a new point
template<class T >
void add (const std::vector< const math::FixedColVector< T, 2 > > &ps)
 adds new points
const core::Img32sgetImage () const
 returns current hough-table image
const core::Img32fgetInhibitionMap () const
 returns current gaussian inhibition map
void clear ()
 sets all hough table entries to 0
std::vector< math::StraightLine2DgetLines (int max)
 detects up to max lines
std::vector< math::StraightLine2DgetLines (int max, std::vector< float > &significances)
 detects up to max lines and pushes the line significances into given destination vector

Private Member Functions

float r (float rho, float x, float y) const
 internal utility function
int getX (float rho) const
 internal utility function
int getY (float r) const
 internal utility function
float getRho (int x) const
 internal utility function
float getR (int y) const
 internal utility function
void incLut (float rho, float r)
 internal utility function
void incLutBlurred (float rho, float r)
 internal utility function
int & cyclicLUT (int x, int y)
 internal utility function
void apply_inhibition (const utils::Point &p)
 internal utility function
void add_intern (float x, float y)
 internal utility function
void add_intern2 (float x, float y)
 internal utility function
void blur_hough_space_if_necessary ()
 internal utility function

Private Attributes

float m_dRho
utils::Range32f m_rRange
int m_w
int m_h
float m_mr
float m_br
float m_mrho
float m_rInhib
float m_rhoInhib
bool m_gaussianInhibition
bool m_blurHoughSpace
bool m_dilateEntries
bool m_blurredSampling
core::Channel32s m_lut
core::Img32s m_image
core::Img32f m_inhibitImage

Detailed Description

LineDetection class using hough-space line detection

Algorithms

Image lines (of infinite length) can be described by a tuple (rho,r) and the line equation $r = x\cdot cos(rho) + y\cdot sin(rho)$. Each pixel (x,y) belongs potentially to a all lines (rho,r) where this equation is true. Internally, the space of possible lines (sometimes referred a the hough-space) is sampled (internally we use an instance of core::Img32s). Rho is mapped to the x-axis (x=0 -> rho=0, x=width-1 -> rho = 2*M_PI) and r is mapped to the y-axis (y=0 -> r=minR, y=height-1 -> r=maxR). So the size of the internal hough-space becomes 2*M_PI/dRho x (rRange.max-rRange.min)/dR.

When a new border pixel (x,y) is added, the probability of each potential line that intersects (x,y) is increased. Technically this is performed by computing r(rho) for all possible values rho (all samples) with the formula for r above which leads to values (rho,r) which's hough-space entries are increased by one. The best line matches can be computed from the maxima in the resulting hough space.

Optimizations

To enhance line detection performance, the HoughLineDetector provides a set of optimization approaches:

Local inhibition around detected lines

As a single image line, might result in 2 or even more lines in the hough-space (because of spacial noise in the pixels detection procedure), the hough-space is locally inhibited around already detected lines. The amount of this inhibition procedure can be set by the constructor parameters (rInhibitionRange and rhoInhibitionRange).

Gaussian inhibition

Sometimes hard borders of the inhibition sub-window lead to random 2nd and 3rd detected line values. To stabilize this, inhibition can be set up to be 'gaussian-blurred', which means, that hough-table entries that are very close to already detected lines are nearly removed completely and those that are also in the inhibition sub-rect but some pixels away from the detected line center are inhibited less.

Gaussian inhibition

Resulting from the sampling procedure of both, that actual image space and the hough-space, entries in the hough-space might have hard borders or even gaps. To avoid this, three different optimization techniques are provided, which can all be combined.

Blurring the hough space

This means, that the hough-space is simply blurred using a 3x3 linear gaussian filter. This optimization provides much more stable results, but it also entails a higher computational expense.

Dilation of pixel entries

If this optimization is activated, no only the given pixel (x,y) is added internally, but also it's 4 direct neighbour pixels. This also leads to a kind of blurred hough table

Blurred sampling of lines

This optimization changes the line-sampling procedure. When a line is sampled for all rho-values using r = x cos(rho) + y sin(rho), not only the resulting pixel p in the hough table is increased, but also the pixel above, and the pixel below (actually, the exactly computed pixel p is increased by 2 and it's upper and lower neighbour's are increased by one). This again leads to a blurring effect. however, the other two optimzations provides better results. It's worth mention, that this optimization's additional computational expense is low in comparison to the other two optizations.


Constructor & Destructor Documentation

icl::cv::HoughLineDetector::HoughLineDetector ( float  dRho,
float  dR,
const utils::Range32f  rRange,
float  rInhibitionRange,
float  rhoInhibitionRange,
bool  gaussianInhibition = true,
bool  blurHoughSpace = true,
bool  dilateEntries = true,
bool  blurredSampling = false 
)

Create a new HoughLineDetectorInstance.

Parameters:
dRholine angle sampling distance
dRline distance to 0 sampling factor
rRangerange of line distances
rInhibitionRangevertical radius for local inhibition
rhoInhibitionRangehorizontal radius for local inhibition
gaussianInhibitionenables gaussian inhibition
blurHoughSpaceenables hough space blurring
dilateEntriesenables entry dilatation
blurredSamplingenables blurred sampling

Member Function Documentation

void icl::cv::HoughLineDetector::add ( const utils::Point p) [inline]

adds a new point

void icl::cv::HoughLineDetector::add ( const std::vector< utils::Point > &  ps) [inline]

adds new points

void icl::cv::HoughLineDetector::add ( const utils::Point32f p) [inline]

adds a new point

void icl::cv::HoughLineDetector::add ( const std::vector< utils::Point32f > &  ps) [inline]

adds new points

template<class T >
void icl::cv::HoughLineDetector::add ( const math::FixedColVector< T, 2 > &  p) [inline]

adds a new point

template<class T >
void icl::cv::HoughLineDetector::add ( const std::vector< const math::FixedColVector< T, 2 > > &  ps) [inline]

adds new points

void icl::cv::HoughLineDetector::add_intern ( float  x,
float  y 
) [private]

internal utility function

void icl::cv::HoughLineDetector::add_intern2 ( float  x,
float  y 
) [private]

internal utility function

internal utility function

internal utility function

sets all hough table entries to 0

int& icl::cv::HoughLineDetector::cyclicLUT ( int  x,
int  y 
) [inline, private]

internal utility function

returns current hough-table image

returns current gaussian inhibition map

detects up to max lines

std::vector<math::StraightLine2D> icl::cv::HoughLineDetector::getLines ( int  max,
std::vector< float > &  significances 
)

detects up to max lines and pushes the line significances into given destination vector

significances are relative to the first line match, which's significance is always 1.0

float icl::cv::HoughLineDetector::getR ( int  y) const [inline, private]

internal utility function

float icl::cv::HoughLineDetector::getRho ( int  x) const [inline, private]

internal utility function

int icl::cv::HoughLineDetector::getX ( float  rho) const [inline, private]

internal utility function

int icl::cv::HoughLineDetector::getY ( float  r) const [inline, private]

internal utility function

void icl::cv::HoughLineDetector::incLut ( float  rho,
float  r 
) [inline, private]

internal utility function

void icl::cv::HoughLineDetector::incLutBlurred ( float  rho,
float  r 
) [inline, private]

internal utility function

float icl::cv::HoughLineDetector::r ( float  rho,
float  x,
float  y 
) const [inline, private]

internal utility function


Member Data Documentation

core::Channel32s icl::cv::HoughLineDetector::m_lut [private]
utils::Range32f icl::cv::HoughLineDetector::m_rRange [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines