Go to the documentation of this file.00001 #ifndef rgrl_matcher_pseudo_int_3d_h_
00002 #define rgrl_matcher_pseudo_int_3d_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <rgrl/rgrl_matcher.h>
00012 #include <rgrl/rgrl_feature_set.h>
00013 #include <rgrl/rgrl_view.h>
00014 #include <rgrl/rgrl_transformation.h>
00015 #include <rgrl/rgrl_scale.h>
00016 #include <rgrl/rgrl_feature_sptr.h>
00017 #include "rgrl_evaluator.h"
00018 #include <rgrl/rgrl_mask_sptr.h>
00019 #include <rgrl/rgrl_mask.h>
00020 #include <vil3d/vil3d_image_view.h>
00021 #include <vnl/vnl_double_3.h>
00022 #include <vnl/vnl_int_3.h>
00023 #include "rgrl_evaluator_sptr.h"
00024
00025 #if 0 // ITK-specific
00026 template < class PixelType, int Dimension > class itkImage;
00027 #endif
00028
00029 template < class PixelType >
00030 class rgrl_matcher_pseudo_int_3d
00031 : public rgrl_matcher
00032 {
00033 public:
00034
00035 class rgrl_mapped_pixel_type {
00036 public:
00037
00038 vnl_int_3 location;
00039 double intensity;
00040 double weight;
00041 rgrl_mapped_pixel_type(): location(), intensity(0.0), weight(1.0) {}
00042 };
00043
00044 typedef vcl_vector< rgrl_mapped_pixel_type > rgrl_mapped_pixel_vector_type;
00045
00046
00047
00048 rgrl_matcher_pseudo_int_3d( vil3d_image_view<PixelType> const& from_image,
00049 vil3d_image_view<PixelType> const& to_image,
00050 vnl_vector< double > const& from_spacing_ratio,
00051 vnl_vector< double > const& to_spacing_ratio,
00052 rgrl_evaluator_sptr evaluator,
00053 rgrl_mask_sptr mask = 0 );
00054
00055
00056
00057 rgrl_match_set_sptr
00058 compute_matches( rgrl_feature_set const& from_features,
00059 rgrl_feature_set const& to_features,
00060 rgrl_view const& current_view,
00061 rgrl_transformation const& current_xform,
00062 rgrl_scale const& current_scale ,
00063 rgrl_match_set_sptr const& old_matches = 0);
00064
00065
00066 rgrl_type_macro( rgrl_matcher_pseudo_int_3d, rgrl_matcher);
00067
00068 private:
00069
00070
00071 struct mapped_info {
00072 vnl_double_3 physical_, pixel_;
00073 PixelType in_;
00074 };
00075
00076
00077 struct discrete_shift_node {
00078 vnl_int_3 shift_;
00079
00080 double step_;
00081
00082 discrete_shift_node(): shift_(), step_(0.0) {}
00083
00084 discrete_shift_node(const vnl_int_3& shift, const double& step)
00085 : shift_(shift), step_(step) {}
00086
00087 discrete_shift_node operator-() const {
00088 discrete_shift_node that;
00089 that.shift_ = -shift_;
00090 that.step_ = -step_;
00091 return that;
00092 }
00093 };
00094
00095
00096 void
00097 map_region_intensities( rgrl_transformation const& trans,
00098 rgrl_feature_sptr feature_sptr,
00099 rgrl_mapped_pixel_vector_type & mapped_pixels ) const;
00100
00101
00102 void
00103 map_region_intensities( vcl_vector< vnl_vector<int> > const& pixel_locations,
00104 rgrl_transformation const& trans,
00105 rgrl_feature_sptr feature_sptr,
00106 rgrl_mapped_pixel_vector_type & mapped_pixels) const;
00107
00108
00109 void
00110 slide_window(rgrl_feature_sptr mapped_feature,
00111 rgrl_mapped_pixel_vector_type const& mapped_pixels,
00112 rgrl_scale const& current_scale,
00113 vcl_vector< rgrl_feature_sptr > & matched_to_features,
00114 vcl_vector< double > & match_weights ) const;
00115
00116
00117 double compute_response( rgrl_mapped_pixel_vector_type const& mapped_pixels,
00118 vnl_int_3 const& shift ) const;
00119
00120
00121
00122
00123 void sample_pixels_along_direction( vcl_vector<discrete_shift_node>& two_dir_shifts,
00124 vnl_double_3 dir,
00125 double max_length ) const;
00126 private:
00127
00128 #if 0 // ITK-specific
00129 typedef itkImage< PixelType, Dimension > ImageType;
00130 #endif // 0
00131
00132
00133
00134 vil3d_image_view<PixelType> from_image_;
00135 vil3d_image_view<PixelType> to_image_;
00136
00137
00138
00139
00140
00141
00142
00143 rgrl_mask_sptr mask_;
00144 rgrl_evaluator_sptr evaluator_;
00145
00146
00147
00148 vnl_double_3 from_spacing_ratio_;
00149 vnl_double_3 to_spacing_ratio_;
00150 };
00151
00152 #endif // rgrl_matcher_pseudo_int_3d_h_