latest version v1.9 - last update 10 Apr 2010 |
This functor is used to make a fast Hough Line Transform and creates a channel32 transformation accumulator. More...
#include <ltiOrientedHLTransform.h>
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 |
orientedHLTransform & | copy (const orientedHLTransform &other) |
orientedHLTransform & | operator= (const orientedHLTransform &other) |
virtual functor * | clone () const |
const parameters & | getParameters () 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 |
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.
lti::orientedHLTransform::orientedHLTransform | ( | ) |
default constructor, member variable m_iAccuracy is set to 180
lti::orientedHLTransform::orientedHLTransform | ( | const orientedHLTransform & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::orientedHLTransform::~orientedHLTransform | ( | ) | [virtual] |
destructor
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.
src | image with the source data. | |
angle_src | channel with gradient angles. | |
dest | channel32 where the result will be left. |
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.
other | the functor to be copied |
Reimplemented from lti::functor.
int lti::orientedHLTransform::getAccuracy | ( | ) | const |
returns accuracy of Hough Line Transform
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.
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.
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 | ) |
bool lti::orientedHLTransform::setAccuracy | ( | int | iAccuracy | ) |
sets accuracy of Hough Line Transform and creates the appropriate sinus and cosinus integer tables
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!
Reimplemented from lti::functor.