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 template<class T>
00022 inline vil_image_view<T> vil_decimate(const vil_image_view<T> &im, unsigned i_factor,
00023 unsigned j_factor=0)
00024 {
00025 if (j_factor==0) j_factor=i_factor;
00026 return vil_image_view<T>(im.memory_chunk(), im.top_left_ptr(),
00027 im.ni()/i_factor, im.nj()/j_factor, im.nplanes(),
00028 im.istep()*i_factor, im.jstep()*j_factor, im.planestep());
00029 }
00030
00031 vil_image_view_base_sptr vil_decimate(const vil_image_view_base_sptr im, unsigned i_factor,
00032 unsigned j_factor=0);
00033
00034
00035
00036 vil_image_resource_sptr vil_decimate(const vil_image_resource_sptr &src,
00037 unsigned i_factor, unsigned j_factor=0);
00038
00039
00040 class vil_decimate_image_resource : public vil_image_resource
00041 {
00042 public:
00043 vil_decimate_image_resource(vil_image_resource_sptr const&,
00044 unsigned i_factor, unsigned j_factor);
00045
00046 virtual unsigned nplanes() const { return src_->nplanes(); }
00047 virtual unsigned ni() const { return src_->ni() / i_factor_; }
00048 virtual unsigned nj() const { return src_->nj() / j_factor_; }
00049
00050 virtual enum vil_pixel_format pixel_format() const { return src_->pixel_format(); }
00051
00052
00053 virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned n_i,
00054 unsigned j0, unsigned n_j) const;
00055
00056 virtual vil_image_view_base_sptr get_view(unsigned i0, unsigned n_i,
00057 unsigned j0, unsigned n_j) const;
00058
00059
00060 virtual bool put_view(const vil_image_view_base& im, unsigned i0, unsigned j0);
00061
00062
00063 virtual bool get_property(char const* tag, void* property_value = 0) const
00064 {
00065 return src_->get_property(tag, property_value);
00066 }
00067
00068 protected:
00069 vil_image_resource_sptr src_;
00070 unsigned i_factor_;
00071 unsigned j_factor_;
00072 };
00073
00074 #endif // vil_decimate_h_