Go to the documentation of this file.00001
00002 #ifndef vil_plane_h_
00003 #define vil_plane_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 #include <vcl_cassert.h>
00014
00015
00016
00017
00018
00019 template<class T>
00020 inline vil_image_view<T> vil_plane(const vil_image_view<T> &im, unsigned p)
00021 {
00022 assert(p<im.nplanes());
00023 return vil_image_view<T>(im.memory_chunk(),im.top_left_ptr()+p*im.planestep(),im.ni(),im.nj(),1,
00024 im.istep(),im.jstep(),im.planestep());
00025 }
00026
00027
00028
00029
00030
00031
00032
00033
00034 template<class T>
00035 inline vil_image_view<T> vil_planes(const vil_image_view<T> &im,
00036 unsigned first, int skip,
00037 unsigned n)
00038 {
00039 assert(first<im.nplanes());
00040 assert(int(first) + int(n)*skip >= 0);
00041 assert((unsigned)(first + n*skip) <= im.nplanes());
00042 return vil_image_view<T>(im.memory_chunk(),
00043 im.top_left_ptr()+first*im.planestep(),
00044 im.ni(),im.nj(),n,
00045 im.istep(),im.jstep(),skip*im.planestep());
00046 }
00047
00048
00049
00050
00051 vil_image_resource_sptr vil_plane(const vil_image_resource_sptr &src, unsigned p);
00052
00053
00054
00055
00056 class vil_plane_image_resource : public vil_image_resource
00057 {
00058 vil_plane_image_resource(vil_image_resource_sptr const&, unsigned p);
00059 friend vil_image_resource_sptr vil_plane(const vil_image_resource_sptr &src, unsigned p);
00060 public:
00061
00062 virtual unsigned nplanes() const { return 1; }
00063 virtual unsigned ni() const { return src_->ni(); }
00064 virtual unsigned nj() const { return src_->nj(); }
00065
00066 virtual enum vil_pixel_format pixel_format() const { return src_->pixel_format(); }
00067
00068 virtual vil_image_view_base_sptr get_copy_view(unsigned i0, unsigned ni,
00069 unsigned j0, unsigned nj) const;
00070
00071 virtual vil_image_view_base_sptr get_view(unsigned i0, unsigned ni,
00072 unsigned j0, unsigned nj) const;
00073
00074
00075
00076 virtual bool put_view(const vil_image_view_base& im, unsigned i0,
00077 unsigned j0);
00078
00079
00080 virtual bool get_property(char const* tag, void* property_value = 0) const {
00081 return src_->get_property(tag, property_value); }
00082
00083 protected:
00084
00085 vil_image_resource_sptr src_;
00086
00087 unsigned plane_;
00088 };
00089
00090 #endif // vil_plane_h_