contrib/rpl/rgrl/rgrl_feature_trace_pt.h
Go to the documentation of this file.
00001 #ifndef rgrl_feature_trace_pt_h_
00002 #define rgrl_feature_trace_pt_h_
00003 //:
00004 // \file
00005 // \author Amitha Perera
00006 // \date   Feb 2003
00007 
00008 #include "rgrl_feature.h"
00009 #include <vcl_vector.h>
00010 #include <vcl_iosfwd.h>
00011 
00012 //: Represent a point along a trace (of a vessel, neuron, etc.)
00013 //
00014 // A trace point is characterized by a location and a tangent along
00015 // the trace.
00016 //
00017 class rgrl_feature_trace_pt
00018   : public rgrl_feature
00019 {
00020  public:
00021   typedef vcl_vector<rgrl_feature_sptr >  feature_vector;
00022 
00023  public:
00024   //: Constructor
00025   //  should not be used by anything other than the reader.
00026   //  use the other constructors insead.
00027   // rgrl_feature_trace_pt();
00028 
00029   //:  Constructor to initialize feature_trace_pt location.
00030   rgrl_feature_trace_pt( vnl_vector<double> const& loc,
00031                          vnl_vector<double> const& tangent );
00032 
00033   //:  Constructor to initialize feature_trace_pt location that has a length along the tangent and an normal.
00034   rgrl_feature_trace_pt( vnl_vector<double> const& loc,
00035                          vnl_vector<double> const& tangent,
00036                          double                    length,
00037                          double                    radius );
00038 
00039   //: read in feature
00040   virtual
00041   bool read( vcl_istream& is, bool skip_tag=false );
00042 
00043   //: write out feature
00044   virtual
00045   void write( vcl_ostream& os ) const;
00046 
00047   virtual vnl_vector<double> const&
00048   tangent() const;
00049 
00050   virtual vnl_matrix<double> const&
00051   error_projector() const;
00052 
00053   //: The result is a rgrl_feature_trace_pt, without transforming the radius/length parameters
00054   virtual rgrl_feature_sptr
00055   transform( rgrl_transformation const& xform ) const;
00056 
00057   //:
00058   // The result is a vector of boundary locations in the direction of the normal
00059   // in the plane defined by the tangent and in_direction.
00060   //
00061   //  CAVEAT: This design is not good enough for 3D trace points, since it only
00062   //          produces 2 boundary constraints. This function should be revised
00063   //          later for 3D.
00064   //
00065   //  Chuck's comment:  I'm not sure this should be here.  It can
00066   //  easily be extracted in an arbitrary set of dimensions from a
00067   //  normal subspace and the radius.
00068   virtual feature_vector
00069   boundary_points(vnl_vector<double> const& in_direction) const;
00070 
00071   virtual unsigned int
00072   num_constraints() const;
00073 
00074   // Defines type-related functions
00075   rgrl_type_macro( rgrl_feature_trace_pt, rgrl_feature );
00076 
00077   //: Return a matrix whose columns form the subspace normal to the trace tangent.
00078   virtual vnl_matrix<double> const&
00079   normal_subspace();
00080 
00081   double length() const { return length_; }
00082   double radius() const { return radius_; }
00083 
00084   //:  Compute the signature weight between two features.
00085   virtual double absolute_signature_weight( rgrl_feature_sptr other ) const;
00086 
00087   //: make a clone copy
00088   virtual rgrl_feature_sptr clone() const;
00089 
00090   //  Chuck's note:  I am beginning to wonder if we are trying to do
00091   //  too much here.  Perhaps we should be make a subclass for the
00092   //  region-based estimator.
00093 
00094  protected:
00095   friend class rgrl_feature_reader;
00096   //:
00097   // Create an uninitialized feature with enough space to store a dim
00098   // dimensional feature. The error projection matrix is initialized
00099   // to the identity.
00100   //
00101   rgrl_feature_trace_pt();
00102 
00103   // to be able to use the protected constructor
00104   friend rgrl_feature_sptr
00105          rgrl_feature_reader( vcl_istream& is );
00106 
00107   vnl_vector<double> tangent_;
00108   vnl_matrix<double> error_proj_;
00109  private:
00110 
00111   //: The basis for the subspace of vectors normal to the tangent direction.
00112   //  This is normal subspace.  It is computed once, when first needed, and cached.
00113   //  This is because the feature location and normal are fixed.
00114   bool subspace_cached_;
00115   vnl_matrix< double > normal_subspace_;
00116 
00117   //  Chuck's note:  We'll have to be careful with the meaning of
00118   //  these.  For example, in aligning extracted vessel boundaries,
00119   //  the radius_ might mean the half-width of the vessel, whereas in
00120   //  the pseudo-feature-based registration application, you might
00121   //  want the radius to be slightly larger...
00122 
00123   double length_;
00124   double radius_;
00125 };
00126 
00127 #endif