Go to the documentation of this file.00001
00002 #ifndef vil_decimate_h_
00003 #define vil_decimate_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011 #include <vil/vil_image_resource.h>
00012 #include <vil/vil_image_view.h>
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 template<class T>
00023 inline vil_image_view<T> vil_decimate(const vil_image_view<T> &im, unsigned i_factor,
00024 unsigned j_factor=0)
00025 {
00026 if (j_factor==0) j_factor=i_factor;
00027
00028 return vil_image_view<T>(im.memory_chunk(), im.top_left_ptr(),
00029 (im.ni()+i_factor-1u)/i_factor, (im.nj()+j_factor-1u)/j_factor, im.nplanes(),
00030 im.istep()*i_factor, im.jstep()*j_factor, im.planestep());
00031 }
00032
00033 vil_image_view_base_sptr vil_decimate(const vil_image_view_base_sptr im, unsigned i_factor,
00034 unsigned j_factor=0);
00035
00036
00037
00038 vil_image_resource_sptr vil_decimate(const vil_image_resource_sptr &src,
00039 unsigned i_factor, unsigned j_factor=0);
00040
00041
00042 class vil_decimate_image_resource : public vil_image_resource
00043 {
00044 public:
00045 vil_decimate_image_resource(vil_image_resource_sptr const&,
00046 unsigned i_factor, unsigned j_factor);
00047
00048 virtual unsigned nplanes() const { return src_->nplanes(); }
00049 virtual unsigned ni() const { return src_->ni() / i_factor_; }
00050 virtual unsigned nj() const { return src_->nj() / j_factor_; }
00051
00052 virtual enum vil_pixel_format pixel_format() const { return src_->pixel_format(); }
00053
00054
00055 virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00056 unsigned j0, unsigned n_j) const;
00057
00058 virtual vil_image_view_base_sptr get_view(unsigned i0, unsigned n_i,
00059 unsigned j0, unsigned n_j) const;
00060
00061
00062 virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00063
00064
00065 virtual bool get_property(char const* tag, void* property_value = 0) const
00066 {
00067 return src_->get_property(tag, property_value);
00068 }
00069
00070 protected:
00071 vil_image_resource_sptr src_;
00072 unsigned i_factor_;
00073 unsigned j_factor_;
00074 };
00075
00076 #endif // vil_decimate_h_