JG ROOT Tools libraries
version 5.0 - august 2014
|
#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 |
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.
RHoughTransform::RHoughTransform | ( | TH2 * | hptr = NULL , |
u_int | nth = 0 , |
||
u_int | nr = 0 , |
||
double | rmax = 0. , |
||
double | thr = 0. , |
||
const string & | id = "" |
||
) |
Constructor.
hptr | source (image) histogram |
nth | number of bins of angle (0-180 deg) axis of the Hough transform |
nr | number of bins of distance axis of the Hough transform |
rmax | maximum distance to consider |
thr | threshold for points selection |
id | transform identifier (name) |
|
virtual |
Destructor.
References ResetTransform().
|
private |
Macro from GCpp library that defines the following functions:
|
inline |
Return the option flags for the transform.
References options.
|
inline |
Return true if the option for center reference point is set.
References optCenter, and options.
Referenced by ComputeTransform(), SetOptionCenterRef(), SetOptionCornerRef(), and SetTransform().
|
inline |
|
inline |
Return true if the option for threshold validation is set.
References options, and optThreshold.
Referenced by GetWeight().
|
inline |
Return true if the option for weight from amplitude is set.
References optAmplitude, and options.
Referenced by ComputeTransform(), and GetWeight().
|
inline |
Return true if the options for weight from amplitude and threshold validation are both set.
References optAmplitude, options, and optThreshold.
|
inline |
Return true if the option for smoothing the Hough transform histogram is set.
References options, and optSmooth.
Referenced by ComputeTransform().
|
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().
|
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().
|
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.
thr | indicates whether the threshold is considered |
References ComputeTransform(), hough_histo, optAmplitude, options, and optThreshold.
|
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.
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Return the pointer to the source image histogram.
References src_histo.
|
inline |
Return the pointer to the Hough transform histogram.
References hough_histo.
|
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.
hname | created histogram name |
References GetWeight(), and src_histo.
|
inline |
Return the center point of the source histogram.
References src_center.
|
inline |
Return the center point of the source histogram.
References src_center.
|
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.
hptr | source (image) histogram |
thr | threshold for points selection |
References ComputeTransform(), hough_histo, SetThreshold(), and src_histo.
|
inlinevirtual |
Set the threshold value to take a point in the analysis.
thr | threshold value |
References threshold.
Referenced by SetSourceHisto().
|
virtual |
Reset the transformation data. If created, the Hough histogram is deleted.
References hough_histo.
Referenced by SetOptionCenterRef(), SetOptionCornerRef(), SetTransform(), and ~RHoughTransform().
|
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.
nth | number of bins of angle (0-180 deg) axis of the Hough transform |
nr | number of bins of distance axis of the Hough transform |
rmax | maximum distance to consider |
id | transform identifier (name) |
calc | whether the Hough transform histogram is computed |
References ComputeTransform(), GetOptionCenterRef(), hough_histo, hough_id, ResetTransform(), src_center, and src_histo.
|
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().
|
virtual |
Return the weight of a point according to the current options of the transform class.
pval | amplitude 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.
theta | returned angle value (degree) |
dist | returned distance value |
References hough_histo.
Referenced by CreateLine(), CreateNormal(), and SearchLineSuppress().
|
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.
theta | line angle parameter (degree) |
dist | line distance (to center) parameter |
width | distance to the line of points to remove |
mode | suppression mode:
|
sdiv | histogram bins subdivision |
References GetWeight(), src_center, and src_histo.
Referenced by SearchLineSuppress().
|
inlinevirtual |
Set the configuration for line suppression in the source image for line search with suppression of lines already found.
mode | selected suppression mode |
width | line width (thickness) |
References suppress_mode, and suppress_width.
|
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.
hthr | threshold in the Hough transform to accept a line detection |
nlmax | maximum number of lines to search (0 for no limit) |
thtab | array of resulting angles (if not NULL) |
rtab | array of resulting distances (if not NULL) |
htab | array of resulting Hough transform maxima (if not NULL) |
sdiv | image histogram bins subdivision for line suppression |
References ComputeTransform(), GetHoughMaximum(), hough_histo, src_histo, suppress_mode, suppress_width, and SuppressSourceLine().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Set the line drawing attributes.
References line_att.
|
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.
theta | angle (in degree) |
dist | distance 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.
theta | angle (in degree) |
dist | distance from the center |
References line_att, and src_center.
RHoughTransform::ClassDef | ( | RHoughTransform | , |
0 | |||
) |
For ROOT dictionary.
|
staticprivate |
Option for reference point at the center of the image histogram
Referenced by GetOptionCenterRef(), GetOptionCornerRef(), SetOptionCenterRef(), and SetOptionCornerRef().
|
staticprivate |
Option for threshold on histogram amplitude for contributing to the analysis
Referenced by GetOptionThreshold(), GetOptionThresholdAmplWeight(), SetOptionAmplWeight(), and SetOptionUnitWeight().
|
staticprivate |
Option for amplitude as weight of histogram point
Referenced by GetOptionAmplWeight(), GetOptionThresholdAmplWeight(), SetOptionAmplWeight(), and SetOptionUnitWeight().
|
staticprivate |
Option for smoothing the Hough transform histogram
Referenced by GetOptionSmooth(), SetOptionNoSmooth(), and SetOptionSmooth().
|
staticprivate |
Mode for line suppression: sharp cut
|
staticprivate |
Mode for line suppression: gauss shape reduction