JG ROOT Tools libraries
version 5.0 - august 2014
|
#include <RHoughTransform3D.hh>
Public Member Functions | |
Constructors, affectation, destructor | |
RHoughTransform3D (TH3 *hptr=NULL, u_short div=2, u_int nxy=0, double xymax=0., double thr=0., const string &id="") | |
virtual | ~RHoughTransform3D () |
Transform analysis options | |
u_int | GetOptions () const |
bool | GetOptionThreshold () const |
bool | GetOptionAmplWeight () const |
bool | GetOptionThresholdAmplWeight () const |
bool | GetOptionSmooth () const |
virtual void | SetOptionAmplWeight (bool thr=false) |
virtual void | SetOptionUnitWeight () |
virtual void | SetOptionSmooth () |
virtual void | SetOptionNoSmooth () |
virtual void | SetOptionDegree () |
virtual void | SetOptionRadian () |
virtual bool | IsOptionDegree () const |
virtual bool | IsOptionRadian () const |
Transform analysis parameters | |
TH3 * | GetSourceHisto () const |
TH3 * | GetWeightHisto (const string &hname="") const |
virtual double | GetWeight (double pval) const |
const TVector3 & | GetSourceCenter () const |
TVector3 & | GetSourceCenter () |
virtual void | SetSourceCenter (const TVector3 &ctr) |
virtual int | SetSourceHisto (TH3 *hptr, double thr=0.) |
virtual void | SetThreshold (double thr) |
virtual void | ResetSourceData () |
virtual void | InitSourceData () |
virtual void | UpdateSourceData () |
virtual void | ResetTesselation () |
virtual const RSphereTesselation & | SetTesselation (u_short div) |
int | GetNpoints () const |
int | GetNsegments () const |
const RSphereTesselation & | GetSphereTesselation () const |
const RTesselationPoint & | GetPoint (int ip) const |
const RTesselationSegment & | GetSegment (int is) const |
virtual void | SetTransformId (const string &id) |
virtual void | ResetTransform () |
virtual void | ResetTransformMain () |
virtual void | ResetTransformLocal () |
virtual TH2 * | SetTransformMain (u_int nxy, double xymax) |
virtual TH2 * | SetTransformLocal (u_int nxy, double dxy, u_int na, double da) |
Transform analysis functions | |
virtual int | SetAnalysisMain () |
virtual int | SetAnalysisLocal () |
virtual int | ComputeTransformXY (u_int ip) |
virtual int | ComputeTransformXY (double theta, double phi, bool deg=false) |
virtual int | ComputeTransformXY (TVector3 ux, TVector3 uy) |
TH2 * | GetLocalHistoAngle () |
TH2 * | GetLocalHistoUxUy () |
virtual void | ResetAnalysis () |
virtual int | AnalyseTransformMain () |
virtual int | AnalyseTransformLocal () |
double | GetMaxScore () const |
double | GetMaxScore (double &theta, double &phi, double &ux, double &uy) const |
virtual void | SuppressSourceLine (double theta, double phi, double ux, double uy, double width, u_short mode=modeCut, u_short sdiv=1) |
virtual void | SuppressSourceLine (TVector3 Pt, TVector3 dir, double width, u_short mode=modeCut, u_short sdiv=1) |
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 () |
TPolyMarker3D * | CreatePoints3D () const |
TPolyLine3D * | CreateSegment3D (int is) const |
TList * | CreateLines3D (const TAttLine latt=TAttLine(kRed+1, 2, 1)) const |
TList * | CreateScorePoints3D (Color_t col=kAzure+1, Style_t sty=20, double siz=1.0) const |
TList * | CreateLocalPoints3D (Color_t col=kRed+1, Style_t sty=20, double siz=1.0) const |
TPolyLine3D * | CreateLine3D () const |
TPolyLine3D * | CreateLine3D (double theta, double phi, double ux, double uy) const |
ClassDef (RHoughTransform3D, 0) | |
Protected Attributes | |
RSphereTesselation | sphere |
Discretized representation of directions on a sphere. | |
int * | sph_pts |
Array of selected points for unique representation of 3D directions. | |
int * | sph_seg |
Array of segments connecting the selected points. | |
TVector3 * | sph_ux |
Unit X vector for discretization directions. | |
TVector3 * | sph_uy |
Unit X vector for discretization directions. | |
double * | sph_score |
Score for discretization directions. | |
u_int | npts |
Number of selected points. | |
u_int | nseg |
Number of selected segments. | |
TH3 * | src_histo |
Pointer to the histogram to analyse. | |
TVector3 | src_center |
Image histogram center. | |
double | threshold |
Threshold value. | |
u_int | src_data_dim |
Reduced source data dimension. | |
u_int | src_data_num |
Number of source data points. | |
TVector3 * | src_data_pos |
Array of source data point positions. | |
double * | src_data_weight |
Array of source data point weight. | |
TH2 * | h_anal_xy |
Pointer to the Ux-Uy weight histogram for the analysed direction. | |
string | hxy_id |
Identifier for created histogram name. | |
double | hxy_max |
Maximum value for current Ux-Uy weight histogram. | |
double | hxy_max_x |
X value for analysis maximum. | |
double | hxy_max_y |
Y value for analysis maximum. | |
double | hxy_max_theta |
Theta value for analysis maximum. | |
double | hxy_max_phi |
Phi value for analysis maximum. | |
bool | analysis_done |
Whether the analysis has been performed. | |
double | hxy_last_score |
Maximum score for current direction. | |
double | hxy_last_x |
X value for current direction maximum. | |
double | hxy_last_y |
Y value for current direction maximum. | |
double | hxy_last_theta |
Theta value for current direction maximum. | |
double | hxy_last_phi |
Phi value for current direction maximum. | |
TH2 * | h_main_xy |
Pointer to the Ux-Uy score histogram for the main analysis (all directions) | |
TH2 * | h_local_xy |
Pointer to the Ux-Uy score histogram for the improved local analysis. | |
TH2 * | h_local_ang |
Pointer to the Theta-Phi score histogram for the improved local analysis. | |
TVector3 * | pt_local |
Array of vectors from local analysis. | |
bool | local_analysis |
Whether the ongoing analysis is local. | |
TAttLine | line_att |
Lines draw attributes (ROOT) | |
u_int | options |
Transform options. | |
Private Member Functions | |
GObject (RHoughTransform3D) | |
Static Private Attributes | |
static double | epsilon = 0.0001 |
static const u_int | optThreshold = 0x00000002 |
static const u_int | optAmplitude = 0x00000004 |
static const u_int | optSmooth = 0x00000008 |
static const u_int | optdegree = 0x00000010 |
static const u_short | modeCut = 0x0000 |
static const u_short | modeGaus = 0x0001 |
static const double | rad2deg = 180./TMath::Pi() |
static const double | deg2rad = TMath::Pi()/180. |
This class is a 3D adaptation of the Hough transform analysis, in order to search for lines in a 3D histogram.
The discretization of 3D directions is based on the tesselation of a sphere starting from an icosahedron (see class RSphereTesselation). The analysis is limited to the directions on the unit sphere defining unique directions, then only half of the tesselation points are considered.
Line detection main procedure
The line searching principle is the following:
Main procedure parameters:
Line detection improvement
The main detection procedure precision is limited to the sphere tessalation. Once a line is detected, a local analysis allows to refine the line parameters around the result of the main procedure.
Multiple lines search: detected line suppression
Configuration at construction time:
Configuration functions:
The main function to perform the line analysis search is RHoughTransform3D::AnalyseTransformMain().
This function computes the score histogram (Ux,Uy) for each direction of the 3D directions discretization. The direction with maximum score is memorized as the result of the analysis.
The score histogram for 1 direction is filled with the RHoughTransform3D::ComputeTransformXY() function.
RHoughTransform3D::RHoughTransform3D | ( | TH3 * | hptr = NULL , |
u_short | div = 2 , |
||
u_int | nxy = 0 , |
||
double | xymax = 0. , |
||
double | thr = 0. , |
||
const string & | id = "" |
||
) |
Constructor.
hptr | source (image) histogram |
div | sphere tesselation division |
nxy | number of bins of Ux-Uy weight histogram |
xymax | maximum distance to consider |
thr | threshold for points selection |
id | transform identifier (name) |
|
virtual |
Destructor.
References ResetSourceData(), and 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 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 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 ComputeTransformXY().
|
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 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 optAmplitude, options, and optThreshold.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Return true is the angles are given in degrees.
References optdegree, and options.
Referenced by AnalyseTransformLocal(), and IsOptionRadian().
|
inlinevirtual |
Return true is the angles are given in radians.
References IsOptionDegree().
|
inline |
Return the pointer to the source image histogram.
References src_histo.
TH3 * RHoughTransform3D::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.
|
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 GetWeightHisto(), and UpdateSourceData().
|
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 |
Define the histogram center for transformations.
ctr | center point |
References src_center, src_histo, and UpdateSourceData().
|
virtual |
Set the source (image) histogram. The function returns 0 if no error occured.
hptr | source (image) histogram |
thr | threshold for points selection |
References SetThreshold(), src_histo, and UpdateSourceData().
|
inlinevirtual |
Set the threshold value to take a point in the analysis.
thr | threshold value |
References threshold.
Referenced by SetSourceHisto().
|
virtual |
Function that deletes the source data arrays built from the source histogram.
References src_data_dim, src_data_num, src_data_pos, and src_data_weight.
Referenced by InitSourceData(), and ~RHoughTransform3D().
|
virtual |
Function that creates the source data arrays built from the source histogram, if needed.
References ResetSourceData(), src_data_dim, src_data_num, src_data_pos, src_data_weight, and src_histo.
Referenced by UpdateSourceData().
|
virtual |
Function that fills the source data arrays built from the source histogram, if needed.
References epsilon, GetWeight(), InitSourceData(), src_center, src_data_dim, src_data_num, src_data_pos, src_data_weight, and src_histo.
Referenced by SetSourceCenter(), SetSourceHisto(), and SuppressSourceLine().
|
virtual |
|
virtual |
Function that defines the discretization level of the directions in 3D space, from the number of iterations in the tesselation of a unit sphere.
div | icosahedron division number |
References RSolidTesselation::GetDivision(), RSolidTesselation::GetNpoints(), RSolidTesselation::GetNsegments(), RTesselationSegment::GetP0(), RTesselationSegment::GetP1(), RSolidTesselation::GetPoint(), RSolidTesselation::GetSegment(), RSphereTesselation::GetVectUx(), RSphereTesselation::GetVectUy(), RTesselationPoint::GetX(), RTesselationPoint::GetY(), RTesselationPoint::GetZ(), RSphereTesselation::InitData(), npts, nseg, ResetTesselation(), sph_pts, sph_score, sph_seg, sph_ux, sph_uy, sphere, and RSphereTesselation::SubDivide().
|
inline |
Return the number of effective points for unique discretization of 3D directions.
References npts.
|
inline |
Return the number of effective segments from the unique discretization of 3D directions.
References nseg.
|
inline |
Return the objet defining the sphere tesselation for the 3D space directions discretization.
References sphere.
|
inline |
Return a point (by constant reference).
ip | point index |
References RSolidTesselation::GetPoint(), sph_pts, and sphere.
|
inline |
Return a segment (by constant reference).
is | segment index |
References RSolidTesselation::GetSegment(), sph_seg, and sphere.
|
inlinevirtual |
Define the base name for created histogram. The analysis transforms (main and local) must be resetted to recreate the histograms. The effective histogram names are:
id | histograms base name identifier |
References hxy_id.
|
virtual |
Reset the transformation data for the main and improved analysis.
References ResetTransformLocal(), and ResetTransformMain().
Referenced by ~RHoughTransform3D().
|
virtual |
Reset the transformation data for the main analysis.
References h_main_xy.
Referenced by ResetTransform(), and SetTransformMain().
|
virtual |
Reset the transformation data for the improved analysis.
References h_local_ang, h_local_xy, and pt_local.
Referenced by ResetTransform(), and SetTransformLocal().
|
virtual |
Function defining the score histogram for the global transform analysis. The source 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 Ux-Uy weight histogram pointer is returned, otherwise a NULL pointer.
nxy | number of bins of Ux-Uy weight histogram |
xymax | maximum distance to consider |
References h_main_xy, hxy_id, R_H3D_MAIN_XY, ResetTransformMain(), and src_histo.
|
virtual |
Function defining the score histogram for the local transform analysis (see local transform analysis in RHoughTransform3D class documentation).
The global transform data must have been previously defined.
The function creates the (Ux,Uy) score histogram, and also a (theta,phi) histogram that stores the maximum results for (Ux,Uy) for each angle. The axis of angles score histogram are in degrees/radians according to the corresponding option.
If the transform is created successfully, the (Ux,Uy) score histogram pointer is returned, otherwise a NULL pointer.
nxy | number of bins of (Ux,Uy) weight histogram |
dxy | (Ux,Uy) score histogram bin size |
na | number of bins of (theta,phi) score histogram |
da | (theta,phi) score histogram bin size |
References RSphereTesselation::GetAngleMin(), h_local_ang, h_local_xy, h_main_xy, hxy_id, optdegree, options, pt_local, R_H3D_LOCAL_ANG, R_H3D_LOCAL_XY, rad2deg, ResetTransformLocal(), and sphere.
|
virtual |
Select score histogram for the main global analysis.
References h_anal_xy, h_main_xy, and local_analysis.
Referenced by AnalyseTransformMain().
|
virtual |
Select score histogram for the local (improved) analysis.
References h_anal_xy, h_local_ang, h_local_xy, h_main_xy, and local_analysis.
Referenced by AnalyseTransformLocal().
|
virtual |
Function computing the Ux-Uy weight histogram with current parameters, for a point in the current discretization of space.
ip | point index |
References npts, sph_ux, and sph_uy.
Referenced by AnalyseTransformLocal(), AnalyseTransformMain(), and ComputeTransformXY().
|
virtual |
Function computing the Ux-Uy weight histogram with current parameters, for a (theta,phi) direction.
theta | angle with Z axis (0:pi/2) |
phi | XY projection angle (2pi) |
deg | whether angle are in degree |
References ComputeTransformXY(), RNormalUx(), and RNormalUy().
|
virtual |
Function computing the Ux-Uy weight histogram with current parameters, for Ux-Uy plane vectors. The function returns -1 if a new maximum has been found, else 0, or a positive value in case of error.
ux | X unit vector |
uy | Y unit vector |
References GetOptionSmooth(), h_anal_xy, hxy_last_phi, hxy_last_score, hxy_last_theta, hxy_last_x, hxy_last_y, hxy_max, hxy_max_phi, hxy_max_theta, hxy_max_x, hxy_max_y, local_analysis, rad2deg, RGetString(), src_data_num, src_data_pos, src_data_weight, and src_histo.
|
inline |
Return the (theta,phi) weight histogram from local analysis.
References h_local_ang.
|
inline |
Return the (Ux,Uy) weight histogram from local analysis.
References h_local_xy.
|
virtual |
Reset the maximum search analysis.
References analysis_done, hxy_max, hxy_max_phi, hxy_max_theta, hxy_max_x, hxy_max_y, and local_analysis.
Referenced by AnalyseTransformLocal(), and AnalyseTransformMain().
|
virtual |
For all direction in the space discretization, compute the Ux-Uy weight histograms to extract the one with maximum score. The function returns the point corresponding index.
References analysis_done, ComputeTransformXY(), hxy_last_score, hxy_max, npts, ResetAnalysis(), SetAnalysisMain(), and sph_score.
|
virtual |
For all direction of the local analysis, compute the Ux-Uy weight histograms to extract the one with maximum score. The function returns 0 if no error occured.
The results of the analysis are stored in the data accessible with the RHoughTransform3D::GetMaxScore functions.
References analysis_done, ComputeTransformXY(), deg2rad, GetMaxScore(), h_local_ang, h_local_xy, hxy_last_score, hxy_max, IsOptionDegree(), local_analysis, pt_local, rad2deg, ResetAnalysis(), RNormalVectors(), and SetAnalysisLocal().
double RHoughTransform3D::GetMaxScore | ( | ) | const |
Return the maximum score found in current analysis.
References analysis_done, and hxy_max.
Referenced by AnalyseTransformLocal(), CreateLine3D(), and GetMaxScore().
double RHoughTransform3D::GetMaxScore | ( | double & | theta, |
double & | phi, | ||
double & | ux, | ||
double & | uy | ||
) | const |
Return the maximum score found in current analysis. The arguments receive the corresponding coordinate values for this maximum score.
theta | theta angle of maximum score |
phi | phi angle of maximum score |
ux | Ux position in Ux-Uy weight histogram |
uy | Uy position in Ux-Uy weight histogram |
References GetMaxScore(), hxy_max_phi, hxy_max_theta, hxy_max_x, hxy_max_y, optdegree, options, and rad2deg.
|
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 theta angle parameter (degree) |
phi | line phi angle parameter (degree) |
ux | line position along Ux axis |
uy | line position along Uy axis |
width | distance to the line of points to remove (a vector for anisotropic width) |
mode | suppression mode:
|
sdiv | histogram bins subdivision |
References deg2rad, RGetVector(), RNormalVectors(), src_center, and src_histo.
|
virtual |
Create a copy of the source histogram, for which all the bins closer that r from the line defined by the pointPt and the direction dir are set to 0.
Pt | point of the line to suppress |
dir | direction of the line to suppress |
width | distance to the line of points to remove (a vector for anisotropic width) |
mode | suppression mode:
|
sdiv | histogram bins subdivision |
References src_histo, and UpdateSourceData().
|
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 |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Set the line drawing attributes.
References line_att.
|
inline |
Set the line drawing attributes.
References line_att.
TPolyMarker3D * RHoughTransform3D::CreatePoints3D | ( | ) | const |
Create a TPolyMarker3D object (ROOT) from points.
References RSolidTesselation::GetPoint(), RTesselationPoint::GetX(), RTesselationPoint::GetY(), RTesselationPoint::GetZ(), npts, sph_pts, and sphere.
TPolyLine3D * RHoughTransform3D::CreateSegment3D | ( | int | is | ) | const |
Create a TPolyLine3D object (ROOT) from a segment.
is | segment number |
References RTesselationSegment::GetP0(), RTesselationSegment::GetP1(), RSolidTesselation::GetPoint(), RSolidTesselation::GetSegment(), RTesselationPoint::GetX(), RTesselationPoint::GetY(), RTesselationPoint::GetZ(), nseg, sph_seg, and sphere.
Referenced by CreateLines3D().
TList * RHoughTransform3D::CreateLines3D | ( | const TAttLine | latt = TAttLine(kRed+1,2,1 ) | ) | const |
Create a list of TPolyLine3D objects (ROOT) from segments.
latt | line attributes set to all segments |
References CreateSegment3D(), and nseg.
TList * RHoughTransform3D::CreateScorePoints3D | ( | Color_t | col = kAzure+1 , |
Style_t | sty = 20 , |
||
double | sizmax = 1.0 |
||
) | const |
Create a list of 1-point TPolyMarker3D objects (ROOT) from points from the sphere points analysis. The points size is proportional to the score.
col | points color |
sty | points style |
sizmax | point size for the maximum score |
References analysis_done, RSolidTesselation::GetPoint(), RTesselationPoint::GetX(), RTesselationPoint::GetY(), RTesselationPoint::GetZ(), npts, sph_pts, sph_score, and sphere.
TList * RHoughTransform3D::CreateLocalPoints3D | ( | Color_t | col = kRed+1 , |
Style_t | sty = 20 , |
||
double | sizmax = 1.0 |
||
) | const |
Create a list of 1-point TPolyMarker3D objects (ROOT) from points from the local analysis. The points size is proportional to the score.
col | points color |
sty | points style |
sizmax | point size for the maximum score |
References analysis_done, h_local_ang, local_analysis, and pt_local.
TPolyLine3D * RHoughTransform3D::CreateLine3D | ( | ) | const |
Create a 3D line in the source histogram coordinates, with currently defined maximum score line parameters.
References GetMaxScore().
TPolyLine3D * RHoughTransform3D::CreateLine3D | ( | double | theta, |
double | phi, | ||
double | ux, | ||
double | uy | ||
) | const |
Create a 3D line in the source histogram coordinates.
theta | theta angle of maximum score |
phi | phi angle of maximum score |
ux | Ux position in Ux-Uy weight histogram |
uy | Uy position in Ux-Uy weight histogram |
References deg2rad, optdegree, options, RLine3D(), RNormalVectors(), src_center, and src_histo.
RHoughTransform3D::ClassDef | ( | RHoughTransform3D | , |
0 | |||
) |
For ROOT dictionary.
|
staticprivate |
Weight limit for ignoring point
Referenced by UpdateSourceData().
|
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 |
Option for angles in degrees
Referenced by CreateLine3D(), GetMaxScore(), IsOptionDegree(), SetOptionDegree(), SetOptionRadian(), and SetTransformLocal().
|
staticprivate |
Mode for line suppression: sharp cut
|
staticprivate |
Mode for line suppression: gauss shape reduction
|
staticprivate |
Conversion factor from radians to degrees
Referenced by AnalyseTransformLocal(), ComputeTransformXY(), GetMaxScore(), and SetTransformLocal().
|
staticprivate |
Conversion factor from degrees to radians
Referenced by AnalyseTransformLocal(), CreateLine3D(), and SuppressSourceLine().