JG ROOT Tools libraries  version 5.0 - august 2014
RHoughTransform Class Reference

#include <RHoughTransform.hh>

Public Member Functions

Constructors, affectation, destructor
 RHoughTransform (TH2 *hptr=NULL, u_int nth=0, u_int nr=0, double rmax=0., double thr=0., const string &id="")
 
virtual ~RHoughTransform ()
 
Transform analysis options
u_int GetOptions () const
 
bool GetOptionCenterRef () const
 
bool GetOptionCornerRef () const
 
bool GetOptionThreshold () const
 
bool GetOptionAmplWeight () const
 
bool GetOptionThresholdAmplWeight () const
 
bool GetOptionSmooth () const
 
virtual void SetOptionCenterRef ()
 
virtual void SetOptionCornerRef ()
 
virtual void SetOptionAmplWeight (bool thr=false)
 
virtual void SetOptionUnitWeight ()
 
virtual void SetOptionSmooth ()
 
virtual void SetOptionNoSmooth ()
 
Transform analysis functions
TH2 * GetSourceHisto () const
 
const TH2 * GetHoughHisto () const
 
TH2 * GetHoughHisto ()
 
TH2 * GetWeightHisto (const string &hname="") const
 
const TPoint & GetSourceCenter () const
 
TPoint & GetSourceCenter ()
 
virtual int SetSourceHisto (TH2 *hptr, double thr=0.)
 
virtual void SetThreshold (double thr)
 
virtual void ResetTransform ()
 
virtual TH2 * SetTransform (u_int nth, u_int nr, double rmax, const string &id="", bool calc=false)
 
virtual int ComputeTransform ()
 
virtual double GetWeight (double pval) const
 
double GetHoughMaximum (double &theta, double &dist) const
 
virtual void SuppressSourceLine (double theta, double dist, double width, u_short mode=modeCut, u_short sdiv=1)
 
virtual void SetSuppressMode (u_short mode, double width)
 
virtual u_int SearchLineSuppress (double hthr, u_int nlmax=1, double *thtab=NULL, double *rtab=NULL, double *htab=NULL, u_short sdiv=1)
 
ROOT related functions
virtual void SetLineColor (Color_t c)
 
virtual void SetLineWidth (Width_t w)
 
virtual void SetLineStyle (Style_t s)
 
virtual void SetLineAtt (TAttLine &att)
 
const TAttLine & GetLineAtt () const
 
TAttLine & GetLineAtt ()
 
TLine * CreateLine () const
 
TLine * CreateLine (double theta, double dist) const
 
TLine * CreateNormal () const
 
TLine * CreateNormal (double theta, double dist) const
 
 ClassDef (RHoughTransform, 0)
 

Protected Attributes

TH2 * src_histo
 Pointer to the histogram to analyse.
 
TPoint src_center
 Image histogram center.
 
double threshold
 Threshold value.
 
TH2 * hough_histo
 Pointer to the Hough transform histogram.
 
string hough_id
 Name for the transform (histogram name)
 
TAttLine line_att
 Lines draw attributes (ROOT)
 
u_int options
 Transform options.
 
u_short suppress_mode
 Mode for line suppression.
 
double suppress_width
 Line width for suppression.
 

Private Member Functions

 GObject (RHoughTransform)
 

Static Private Attributes

static const u_int optCenter = 0x00000001
 
static const u_int optThreshold = 0x00000002
 
static const u_int optAmplitude = 0x00000004
 
static const u_int optSmooth = 0x00000008
 
static const u_short modeCut = 0x0000
 
static const u_short modeGaus = 0x0001
 

Detailed Description

This class performs Hough transform analysis of the image given by a 2D histogram.

The Hough transform is used to search for lines in an image.

It is supposed to work on points cloud; here, the analysis is done by weighting the contribution of each pixel with the histogram content. The X and Y dimensions of the image histogram should be in the dimension units.

The source image histogram is defined by a pointer to an histogram that is defined outside the RHoughTransform object.

Constructor & Destructor Documentation

RHoughTransform::RHoughTransform ( TH2 *  hptr = NULL,
u_int  nth = 0,
u_int  nr = 0,
double  rmax = 0.,
double  thr = 0.,
const string &  id = "" 
)

Constructor.

Parameters
hptrsource (image) histogram
nthnumber of bins of angle (0-180 deg) axis of the Hough transform
nrnumber of bins of distance axis of the Hough transform
rmaxmaximum distance to consider
thrthreshold for points selection
idtransform identifier (name)
RHoughTransform::~RHoughTransform ( )
virtual

Destructor.

References ResetTransform().

Member Function Documentation

RHoughTransform::GObject ( RHoughTransform  )
private

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
u_int RHoughTransform::GetOptions ( ) const
inline

Return the option flags for the transform.

References options.

bool RHoughTransform::GetOptionCenterRef ( ) const
inline

Return true if the option for center reference point is set.

References optCenter, and options.

Referenced by ComputeTransform(), SetOptionCenterRef(), SetOptionCornerRef(), and SetTransform().

bool RHoughTransform::GetOptionCornerRef ( ) const
inline

Return true if the option for center reference point is not set.

References optCenter, and options.

bool RHoughTransform::GetOptionThreshold ( ) const
inline

Return true if the option for threshold validation is set.

References options, and optThreshold.

Referenced by GetWeight().

bool RHoughTransform::GetOptionAmplWeight ( ) const
inline

Return true if the option for weight from amplitude is set.

References optAmplitude, and options.

Referenced by ComputeTransform(), and GetWeight().

bool RHoughTransform::GetOptionThresholdAmplWeight ( ) const
inline

Return true if the options for weight from amplitude and threshold validation are both set.

References optAmplitude, options, and optThreshold.

bool RHoughTransform::GetOptionSmooth ( ) const
inline

Return true if the option for smoothing the Hough transform histogram is set.

References options, and optSmooth.

Referenced by ComputeTransform().

void RHoughTransform::SetOptionCenterRef ( )
virtual

Define the reference point of the analysis to be the center of the image histogram. If the transform was previously defined, it is resetted, since the analysis range in terms of distance and angles.

References GetOptionCenterRef(), optCenter, options, and ResetTransform().

void RHoughTransform::SetOptionCornerRef ( )
virtual

Define the reference point of the analysis to be the corner of the image histogram. If the transform was previously defined, it is resetted, since the analysis range in terms of distance and angles.

References GetOptionCenterRef(), optCenter, options, and ResetTransform().

void RHoughTransform::SetOptionAmplWeight ( bool  thr = false)
virtual

Set the weight of image histogram bins to be the amplitude. All bins above threshold are taken into account if the threshold is defined.

Parameters
thrindicates whether the threshold is considered

References ComputeTransform(), hough_histo, optAmplitude, options, and optThreshold.

void RHoughTransform::SetOptionUnitWeight ( )
virtual

Set the weight of image histogram bins to be 1. In this case, the threshold is automatically taken into account for bins to be taken into account.

References ComputeTransform(), hough_histo, optAmplitude, options, and optThreshold.

void RHoughTransform::SetOptionSmooth ( )
inlinevirtual

Set the option for smoothing the Hough transform histogram.

References options, and optSmooth.

void RHoughTransform::SetOptionNoSmooth ( )
inlinevirtual

Unset the option for smoothing the Hough transform histogram.

References options, and optSmooth.

TH2 * RHoughTransform::GetSourceHisto ( ) const
inline

Return the pointer to the source image histogram.

References src_histo.

const TH2 * RHoughTransform::GetHoughHisto ( ) const
inline

Return the pointer to the Hough transform histogram.

References hough_histo.

TH2 * RHoughTransform::GetHoughHisto ( )
inline

Return the pointer to the Hough transform histogram.

References hough_histo.

TH2 * RHoughTransform::GetWeightHisto ( const string &  hname = "") const

Create an histogram from the source image histo with weight of each bin according to current options.

Parameters
hnamecreated histogram name

References GetWeight(), and src_histo.

const TPoint & RHoughTransform::GetSourceCenter ( ) const
inline

Return the center point of the source histogram.

References src_center.

TPoint & RHoughTransform::GetSourceCenter ( )
inline

Return the center point of the source histogram.

References src_center.

int RHoughTransform::SetSourceHisto ( TH2 *  hptr,
double  thr = 0. 
)
virtual

Set the source (image) histogram. If a Hough transform was previously set (with another histogram), it is recreated with the new one. The function returns 0 if no error occured.

Parameters
hptrsource (image) histogram
thrthreshold for points selection

References ComputeTransform(), hough_histo, SetThreshold(), and src_histo.

void RHoughTransform::SetThreshold ( double  thr)
inlinevirtual

Set the threshold value to take a point in the analysis.

Parameters
thrthreshold value

References threshold.

Referenced by SetSourceHisto().

void RHoughTransform::ResetTransform ( )
virtual

Reset the transformation data. If created, the Hough histogram is deleted.

References hough_histo.

Referenced by SetOptionCenterRef(), SetOptionCornerRef(), SetTransform(), and ~RHoughTransform().

TH2 * RHoughTransform::SetTransform ( u_int  nth,
u_int  nr,
double  rmax,
const string &  id = "",
bool  calc = false 
)
virtual

Function defining the Hough transform histogram. The image histogram pointer must be defined.

If the maximum distance is 0, it is taken from the image histogram diagonal.

If the transform is created successfully, the Hough transform histogram pointer is returned, otherwise a NULL pointer.

Parameters
nthnumber of bins of angle (0-180 deg) axis of the Hough transform
nrnumber of bins of distance axis of the Hough transform
rmaxmaximum distance to consider
idtransform identifier (name)
calcwhether the Hough transform histogram is computed

References ComputeTransform(), GetOptionCenterRef(), hough_histo, hough_id, ResetTransform(), src_center, and src_histo.

int RHoughTransform::ComputeTransform ( )
virtual

Function computing the Hough transform with current parameters. The image histogram pointer must be defined.

References GetOptionAmplWeight(), GetOptionCenterRef(), GetOptionSmooth(), GetWeight(), hough_histo, src_center, and src_histo.

Referenced by SearchLineSuppress(), SetOptionAmplWeight(), SetOptionUnitWeight(), SetSourceHisto(), and SetTransform().

double RHoughTransform::GetWeight ( double  pval) const
virtual

Return the weight of a point according to the current options of the transform class.

Parameters
pvalamplitude of the point signal

References GetOptionAmplWeight(), GetOptionThreshold(), and threshold.

Referenced by ComputeTransform(), GetWeightHisto(), and SuppressSourceLine().

double RHoughTransform::GetHoughMaximum ( double &  theta,
double &  dist 
) const

Return the angle and distance for the maximum value of the Hough transform histogram.

Parameters
thetareturned angle value (degree)
distreturned distance value

References hough_histo.

Referenced by CreateLine(), CreateNormal(), and SearchLineSuppress().

void RHoughTransform::SuppressSourceLine ( double  theta,
double  dist,
double  width,
u_short  mode = modeCut,
u_short  sdiv = 1 
)
virtual

Create a copy of the source histogram, for which all the bins closer that r from the line defined by theta and dist arguments are set to 0.

Parameters
thetaline angle parameter (degree)
distline distance (to center) parameter
widthdistance to the line of points to remove
modesuppression mode:
  • 0 for sharp cut
  • 1 for gauss shape reduction cut
sdivhistogram bins subdivision

References GetWeight(), src_center, and src_histo.

Referenced by SearchLineSuppress().

void RHoughTransform::SetSuppressMode ( u_short  mode,
double  width 
)
inlinevirtual

Set the configuration for line suppression in the source image for line search with suppression of lines already found.

Parameters
modeselected suppression mode
widthline width (thickness)

References suppress_mode, and suppress_width.

u_int RHoughTransform::SearchLineSuppress ( double  hthr,
u_int  nlmax = 1,
double *  thtab = NULL,
double *  rtab = NULL,
double *  htab = NULL,
u_short  sdiv = 1 
)
virtual

Search for lines in the image histogram. When a line is found, it is suppressed from the image in order to search for the next line.

The function returns the number of lines found.

Be careful when setting no limit to the number of lines, since in case of problem, it may result in writing results out of the boundaries of thtab and rtab if they are defined.

Parameters
hthrthreshold in the Hough transform to accept a line detection
nlmaxmaximum number of lines to search (0 for no limit)
thtabarray of resulting angles (if not NULL)
rtabarray of resulting distances (if not NULL)
htabarray of resulting Hough transform maxima (if not NULL)
sdivimage histogram bins subdivision for line suppression

References ComputeTransform(), GetHoughMaximum(), hough_histo, src_histo, suppress_mode, suppress_width, and SuppressSourceLine().

void RHoughTransform::SetLineColor ( Color_t  c)
inlinevirtual

Set the line drawing color.

Parameters
cline color

References line_att.

void RHoughTransform::SetLineWidth ( Width_t  w)
inlinevirtual

Set the line drawing width.

Parameters
wline width

References line_att.

void RHoughTransform::SetLineStyle ( Style_t  s)
inlinevirtual

Set the line drawing style.

Parameters
sline style

References line_att.

void RHoughTransform::SetLineAtt ( TAttLine &  att)
inlinevirtual

Set the line drawing attributes.

Parameters
attline attributes

References line_att.

const TAttLine & RHoughTransform::GetLineAtt ( ) const
inline

Set the line drawing attributes.

References line_att.

TAttLine & RHoughTransform::GetLineAtt ( )
inline

Set the line drawing attributes.

References line_att.

TLine * RHoughTransform::CreateLine ( ) const

Create a line in the source histogram coordinates from current Hough transform maximum.

References GetHoughMaximum().

TLine * RHoughTransform::CreateLine ( double  theta,
double  dist 
) const

Create a line in the source histogram coordinates.

Parameters
thetaangle (in degree)
distdistance from the center

References line_att, src_center, and src_histo.

TLine * RHoughTransform::CreateNormal ( ) const

Create the normal line of a point in the Hough parameter space from current transform maximum. The line starts from the image center with a length corresponding to the distance.

References GetHoughMaximum().

TLine * RHoughTransform::CreateNormal ( double  theta,
double  dist 
) const

Create the normal line of a point in the Hough parameter space. The line starts from the image center with a length corresponding to the distance.

Parameters
thetaangle (in degree)
distdistance from the center

References line_att, and src_center.

RHoughTransform::ClassDef ( RHoughTransform  ,
 
)

For ROOT dictionary.

Member Data Documentation

const u_int RHoughTransform::optCenter = 0x00000001
staticprivate

Option for reference point at the center of the image histogram

Referenced by GetOptionCenterRef(), GetOptionCornerRef(), SetOptionCenterRef(), and SetOptionCornerRef().

const u_int RHoughTransform::optThreshold = 0x00000002
staticprivate

Option for threshold on histogram amplitude for contributing to the analysis

Referenced by GetOptionThreshold(), GetOptionThresholdAmplWeight(), SetOptionAmplWeight(), and SetOptionUnitWeight().

const u_int RHoughTransform::optAmplitude = 0x00000004
staticprivate

Option for amplitude as weight of histogram point

Referenced by GetOptionAmplWeight(), GetOptionThresholdAmplWeight(), SetOptionAmplWeight(), and SetOptionUnitWeight().

const u_int RHoughTransform::optSmooth = 0x00000008
staticprivate

Option for smoothing the Hough transform histogram

Referenced by GetOptionSmooth(), SetOptionNoSmooth(), and SetOptionSmooth().

const u_short RHoughTransform::modeCut = 0x0000
staticprivate

Mode for line suppression: sharp cut

const u_short RHoughTransform::modeGaus = 0x0001
staticprivate

Mode for line suppression: gauss shape reduction


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