Go to the documentation of this file.00001
00002 #ifndef vil_flatten_h_
00003 #define vil_flatten_h_
00004
00005
00006
00007
00008 #include <vil/vil_image_view.h>
00009 #include <vil/vil_crop.h>
00010 #include <vil/vil_plane.h>
00011
00012
00013
00014
00015
00016
00017 template<class T>
00018 inline vil_image_view<T> vil_flatten_planes(const vil_image_view<T> &im)
00019 {
00020 if (im.nplanes() == 1) return im;
00021 if (im.jstep() * im.nj() == im.planestep())
00022 {
00023 return vil_image_view<T>(im.memory_chunk(),
00024 im.top_left_ptr(),
00025 im.ni(), im.nj() * im.nplanes(), 1,
00026 im.istep(),im.jstep(),im.ni() * im.nj() * im.nplanes());
00027 }
00028
00029 vil_image_view<T> ret(im.ni(), im.nj() * im.nplanes(), 1);
00030 for (unsigned p=0, n=im.nplanes(); p<n; ++p)
00031 {
00032 vil_image_view<T> tile = vil_crop(ret, 0, im.ni(), im.nj()*p, im.nj());
00033 vil_copy_reformat(vil_plane(im, p), tile);
00034 }
00035
00036 return ret;
00037 }
00038
00039 #endif // vil_flatten_h_