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