Go to the documentation of this file.00001
00002
00003
00004
00005 #include "rgrl_feature_point_region.h"
00006 #include <rgrl/rgrl_util.h>
00007 #include <rgrl/rgrl_transformation.h>
00008
00009 rgrl_feature_point_region::
00010 rgrl_feature_point_region( vnl_vector<double> const& loc, double radius )
00011 : rgrl_feature_point( loc ),
00012 radius_(radius)
00013 { }
00014
00015 rgrl_feature_point_region::
00016 rgrl_feature_point_region( unsigned dim )
00017 : rgrl_feature_point( dim ),
00018 radius_( 0 )
00019 {
00020 }
00021
00022 rgrl_feature_sptr
00023 rgrl_feature_point_region::
00024 transform( rgrl_transformation const& xform ) const
00025 {
00026 rgrl_feature_point_region* result = new rgrl_feature_point_region( this->location().size() );
00027
00028
00029 rgrl_feature_sptr result_sptr = result;
00030
00031
00032
00033 xform.map_location( this->location_, result->location_ );
00034
00035
00036
00037 result -> radius_ = this -> radius_;
00038
00039 return result_sptr;
00040 }
00041
00042
00043 void
00044 rgrl_feature_point_region ::
00045 generate_pixel_coordinates( vnl_vector< double > const& spacing_ratio )
00046 {
00047
00048
00049
00050
00051
00052
00053 unsigned int dim = this -> location_ . size();
00054 vcl_vector< vnl_vector<double> > directions;
00055 directions.reserve( dim );
00056
00057
00058
00059
00060 vnl_vector< double > location_in_pixel( dim );
00061 vnl_vector< double > radii_in_pixel( dim, radius_ );
00062 vnl_vector< double > directions_in_pixel( dim );
00063
00064 vnl_vector< double > direction_in_pixel( dim );
00065 for ( unsigned int i = 0; i < dim; ++i )
00066 {
00067 location_in_pixel[ i ] = this->location_[ i ] / spacing_ratio[ i ];
00068 radii_in_pixel[i] = radii_in_pixel[i] / spacing_ratio[i];
00069 }
00070
00071
00072 vnl_matrix<double> tangent( dim, dim, vnl_matrix_identity );
00073
00074 for ( unsigned int i = 0; i < dim; ++i )
00075 {
00076 direction_in_pixel = tangent.get_column( i );
00077 for ( unsigned j = 0; j < dim; ++j )
00078 direction_in_pixel[ j ] /= spacing_ratio[ j ];
00079
00080 directions.push_back( direction_in_pixel );
00081 }
00082
00083
00084
00085
00086 rgrl_util_extract_region_locations( location_in_pixel, directions,
00087 radii_in_pixel, pixel_coordinates_ );
00088
00089 pixel_coordinates_cached_ = true;
00090 }
00091
00092 rgrl_feature_sptr
00093 rgrl_feature_point_region::
00094 clone() const
00095 {
00096 return new rgrl_feature_point_region(*this);
00097 }