contrib/rpl/rgrl/rgrl_feature_set_location_masked.h
Go to the documentation of this file.
00001 #ifndef rgrl_feature_set_location_masked_h_
00002 #define rgrl_feature_set_location_masked_h_
00003 //:
00004 // \file
00005 // \brief Derived class to represent point feature set with masked region
00006 // \author Charlene Tsai
00007 // \date   Sep 2003
00008 //
00009 // \verbatim
00010 //  Modifications
00011 //   Peter Vanroose - 14 aug 2004 - moved all impl from .txx to .h to avoid VC60 internal compile error
00012 //   Chuck Stewart - 8 Nov 2005 - added versions of nearest_feature and k_nearest_feature
00013 //      based on point location alone
00014 // \endverbatim
00015 
00016 #include <rgrl/rgrl_feature_set.h>
00017 #include <rgrl/rgrl_mask_sptr.h>
00018 
00019 //: Represents a set of point features, valid in the masked region
00020 //
00021 class rgrl_feature_set_location_masked
00022   : public rgrl_feature_set
00023 {
00024  public:
00025 
00026   rgrl_feature_set_location_masked( rgrl_feature_set_sptr const& fea_set,
00027                                     rgrl_mask_sptr mask )
00028   : rgrl_feature_set( fea_set->all_features(), fea_set->label() ),
00029     fea_set_sptr_( fea_set ),
00030     mask_( mask )
00031   {}
00032 
00033   ~rgrl_feature_set_location_masked() {}
00034 
00035   //:  Return all the features
00036   feature_vector const&
00037   all_features( ) const
00038   { return fea_set_sptr_->all_features(); }
00039 
00040   //:  Return the bounding box encloses the feature set
00041   rgrl_mask_box
00042   bounding_box() const;
00043 
00044   //:  Return the type of feature
00045   virtual
00046   const vcl_type_info&
00047   type() const
00048   { return fea_set_sptr_->type(); }
00049 
00050   void
00051   features_in_region( feature_vector& final_results, rgrl_mask_box const& roi ) const;
00052 
00053   //:  Return the features in a given circle/sphere.
00054   void
00055   features_within_radius( feature_vector& final_results, vnl_vector<double> const& center, double radius ) const;
00056 
00057   //: Nearest feature based on Euclidean distance
00058   rgrl_feature_sptr
00059   nearest_feature( rgrl_feature_sptr const& feature ) const;
00060 
00061   //: Nearest feature based on Euclidean distance
00062   rgrl_feature_sptr
00063   nearest_feature( const vnl_vector<double>& loc ) const;
00064 
00065   //: Return all features within a given Euclidean distance
00066   void
00067   features_within_radius( feature_vector& results, rgrl_feature_sptr const& feature, double distance ) const;
00068 
00069   //: Return the k nearest features based on Euclidean distance
00070   void
00071   k_nearest_features( feature_vector& results, const vnl_vector<double>& loc, unsigned int k ) const;
00072 
00073   //: Return the k nearest features based on Euclidean distance
00074   void
00075   k_nearest_features( feature_vector& results, rgrl_feature_sptr const& feature, unsigned int k ) const;
00076 
00077   // Defines type-related functions
00078   rgrl_type_macro( rgrl_feature_set_location_masked, rgrl_feature_set);
00079 
00080  private:
00081   rgrl_feature_set_sptr  fea_set_sptr_;
00082   rgrl_mask_sptr         mask_;
00083 };
00084 
00085 #endif