LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::orientedHLTransform Class Reference

This functor is used to make a fast Hough Line Transform and creates a channel32 transformation accumulator. More...

#include <ltiOrientedHLTransform.h>

Inheritance diagram for lti::orientedHLTransform:
Inheritance graph
[legend]
Collaboration diagram for lti::orientedHLTransform:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class orientedHLTransform More...

Public Member Functions

 orientedHLTransform ()
 orientedHLTransform (const orientedHLTransform &other)
virtual ~orientedHLTransform ()
virtual const char * getTypeName () const
bool apply (const channel &src, const channel &angle_src, channel32 &dest) const
bool apply (const channel8 &src, const channel &angle_src, channel32 &dest) const
bool apply (const image &src, const channel &angle_src, channel32 &dest) const
bool apply (const channel32 &src, const channel &angle_src, channel32 &dest) const
orientedHLTransformcopy (const orientedHLTransform &other)
orientedHLTransformoperator= (const orientedHLTransform &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool updateParameters ()
int getAccuracy () const
bool setAccuracy (int iAccuracy)
Help methods



bool getHoughSpacePoints (const channel32 &hough, vector< tpoint< float > > &positions, const float stdDevFactor=1.0f, const float hystheresis=0.5f) const
bool getSegmentPoints (const point &imageSize, const float radius, const float angle, point &a, point &b, const point &origin=point(-1,-1)) const

Detailed Description

This functor is used to make a fast Hough Line Transform and creates a channel32 transformation accumulator.

The houghLineTransform::parameters specify what part of a given image/channel is transformed and which point values are considered.

To accelerate the computations, an orientation map containing the angles perpendicular to the edges is used. This can be generated using for example lti::orientationMap.

Two additional methods help in the use of the hough space. The first one detects the local maxima ( getHoughSpacePoints() ), and the second one finds two points that define the line segment found in the image ( getSegmentPoints() ).

The hough space contains as expected two parameters: radius and angle. They are measured from the middle point of the analysed region. The angle is always between 0 and 180 degrees. The radius can be negative and its absolute value will be between 0 and the image diagonal divided by two.

Example:

 #include "ltiOrientedHLTransform.h" // the hough transform
 #include "ltiCannyEdges.h"          // the edge detector
 #include "ltiALLFunctor.h"          // to read png, jpg and bmp images
 #include "ltiDraw.h"                // drawing tool
 #include "ltiViewer.h"              // visualization tool

 // ...

 lti::image inputImg;
 lti::channel8 edges;
 lti::channel angles; // orientation map
 lti::channel32 transformAccu;
  
 // load an image and extract the intensity channel from it
 lti::loadImage imgLoader;
 imgLoader.load("../img/hough1.png",inputImg); // load an image

 // we need the edges
 cannyEdges canny;
 canny.apply(inputImg,edges,angles);

 // create default HLT (Hough Line Transform) using default parameters
 lti::orientedHLTransform HLT;
 
 // The Hough Transform
 HLT.apply(edges,angles,transformAccu);

 // Display the Hough space
 viewer viewHS("Hough Space");
 viewHS.show(transformAccu);
  
 // Now get the local maxima of the transformAccu
 lti::vector< tpoint<float> > maxpos;
 HLT.getHoughSpacePoints(transformAccu,maxpos);
 
 // And draw the found lines in the original image
 lti::draw<rgbPixel> drawer;
 drawer.use(inputImg);
 drawer.setColor(lti::White);
 point a,b;
 for (int k=0;k<maxpos.size();++k) {
   HLT.getSegmentPoints(inputImg.size(),maxpos.at(k).x,maxpos.at(k).y,a,b);
   drawer.line(a,b);
 }
 
 // at last, show the resulting lines
 viewer view("Detected lines");
 view.show(inputImg);

 view.waitButtonPressed(); // wait until the user presses the mouse button
                           // on the viewer window.

Constructor & Destructor Documentation

lti::orientedHLTransform::orientedHLTransform (  ) 

default constructor, member variable m_iAccuracy is set to 180

See also:
m_iAccuracy()
setAccuracy()
getAccuracy()
lti::orientedHLTransform::orientedHLTransform ( const orientedHLTransform other  ) 

copy constructor

Parameters:
other the object to be copied
virtual lti::orientedHLTransform::~orientedHLTransform (  )  [virtual]

destructor


Member Function Documentation

bool lti::orientedHLTransform::apply ( const channel32 src,
const channel angle_src,
channel32 dest 
) const

operates on a copy of the given parameters.

Parameters:
src channel32 with the source data.
angle_src channel with gradient angles.
dest channel32 where the result will be left.
Returns:
true if apply successful or false otherwise.
bool lti::orientedHLTransform::apply ( const image src,
const channel angle_src,
channel32 dest 
) const

Make Hough Transform of the given image and write the transformation accumulator into dest.

operates on a copy of the given parameters.

Parameters:
src image with the source data.
angle_src channel with gradient angles.
dest channel32 where the result will be left.
Returns:
true if apply successful or false otherwise.
bool lti::orientedHLTransform::apply ( const channel8 src,
const channel angle_src,
channel32 dest 
) const

operates on a copy of the given parameters.

Parameters:
src channel8 with the source data.
angle_src channel with gradient angles.
dest channel32 where the result will be left.
Returns:
true if apply successful or false otherwise.
bool lti::orientedHLTransform::apply ( const channel src,
const channel angle_src,
channel32 dest 
) const

operates on a copy of the given parameters.

Parameters:
src channel with the source data (gradient).
angle_src channel with gradient angles.
dest channel32 where the result will be left.
Returns:
true if apply successful or false otherwise.
virtual functor* lti::orientedHLTransform::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Implements lti::functor.

orientedHLTransform& lti::orientedHLTransform::copy ( const orientedHLTransform other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

int lti::orientedHLTransform::getAccuracy (  )  const

returns accuracy of Hough Line Transform

See also:
m_iAccuracy()
Returns:
value of member variable m_iAccuracy
bool lti::orientedHLTransform::getHoughSpacePoints ( const channel32 hough,
vector< tpoint< float > > &  positions,
const float  stdDevFactor = 1.0f,
const float  hystheresis = 0.5f 
) const

This method is used to get the list of points in the parameter space, sorted by their hough transformation value, with the maxima at the beginning.

Parameters:
hough a hough transformation image, as produced by the apply methods
positions the positions of the points found in the hough image, sorted by the hough value. The x value will be the radius (in pixels) and the y value the angle (in radians).
stdDevFactor the average and std. deviation values between all detected maxima will be computed. Only those values greater than the average plus this parameter multiplied by the std. deviation will be considered. Default value 1.0 should be ok.
hystheresis to detect the local maxima a region search starting from preliminary maxima will be done. This value multiplied by the preliminary maxima determine the threshold that must be reached in order to continue the search. The value must be between 0 and 1. If it is choose too low, just the biggest maxima will be found. If too high, too many maxima will be found. Default value 0.5 work well for the most cases.
const parameters& lti::orientedHLTransform::getParameters (  )  const

returns used parameters

Reimplemented from lti::transform.

bool lti::orientedHLTransform::getSegmentPoints ( const point imageSize,
const float  radius,
const float  angle,
point a,
point b,
const point origin = point(-1,-1) 
) const

Given a radius and an angle, compute the two points at the border of the image.

Parameters:
imageSize size of the image for which the points a and b need to be computed
radius radius parameter of the hough space
angle angle parameter of the hough space
a begin point
b end point
origin optional parameter that specifies the origin of the coordinates system in the image. If not given or if it contains negative values, the middle of the image will be used as origin.
virtual const char* lti::orientedHLTransform::getTypeName (  )  const [virtual]

returns the name of this type ("orientedHLTransform")

Reimplemented from lti::transform.

orientedHLTransform& lti::orientedHLTransform::operator= ( const orientedHLTransform other  ) 

alias for copy member

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

bool lti::orientedHLTransform::setAccuracy ( int  iAccuracy  ) 

sets accuracy of Hough Line Transform and creates the appropriate sinus and cosinus integer tables

See also:
m_iAccuracy()
Returns:
true, if successful
virtual bool lti::orientedHLTransform::updateParameters (  )  [virtual]

set functor's parameters.

This member makes a copy of theParam: the functor will keep its own copy of the parameters!

Returns:
true if successful, false otherwise

Reimplemented from lti::functor.


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

Generated on Sat Apr 10 15:27:39 2010 for LTI-Lib by Doxygen 1.6.1