core/vil/vil_decimate.h

Go to the documentation of this file.
00001 // This is core/vil/vil_decimate.h
00002 #ifndef vil_decimate_h_
00003 #define vil_decimate_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Ian Scott.
00010 
00011 #include <vil/vil_image_resource.h>
00012 #include <vil/vil_image_view.h>
00013 
00014 
00015 //: Create a view which is a decimated version of src.
00016 // Doesn't modify underlying data. O(1).
00017 // \relates vil_image_view
00018 // The factor describes the number of input rows (or columns)
00019 // that are equivalent to one output.
00020 // If you don't specify the j_factor, it will be set equal to i_factor.
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 //: decimate to a region of src.
00035 // \relates vil_image_resource
00036 vil_image_resource_sptr vil_decimate(const vil_image_resource_sptr &src,
00037                                      unsigned i_factor, unsigned j_factor=0);
00038 
00039 //: A generic_image adaptor that behaves like a decimated version of its input
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   //: Extra property information
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_

Generated on Mon Sep 8 05:07:45 2008 for core/vil by  doxygen 1.5.1