Go to the documentation of this file.00001
00002 #ifndef vil_tile_images_h_
00003 #define vil_tile_images_h_
00004
00005
00006
00007
00008
00009 #include <vil/vil_image_view.h>
00010 #include <vcl_vector.h>
00011 #include <vcl_cmath.h>
00012 #include <vcl_cassert.h>
00013
00014
00015
00016
00017
00018
00019
00020 template<class T>
00021 inline void vil_tile_images(vil_image_view<T>& big_image,
00022 const vcl_vector<vil_image_view<T> >& patches)
00023 {
00024 unsigned n = patches.size();
00025 unsigned nj = unsigned(vcl_sqrt(float(n)));
00026 unsigned ni = 1+(n-1)/nj;
00027
00028 unsigned pi = patches[0].ni();
00029 unsigned pj = patches[0].nj();
00030 unsigned np = patches[0].nplanes();
00031
00032 big_image.set_size(ni*pi,nj*pj);
00033 big_image.fill(vxl_byte(0));
00034 for (unsigned k=0;k<n;++k)
00035 {
00036 assert(patches[k].ni()==pi && patches[k].nj()== pj &&
00037 patches[k].nplanes()== np);
00038
00039 unsigned i = k%ni;
00040 unsigned j = k/ni;
00041 for (unsigned y=0;y<pj;++y)
00042 for (unsigned x=0;x<pi;++x)
00043 for (unsigned p=0;p<np;++p)
00044 big_image(i*pi+x,j*pj+y,p) = patches[k](x,y,p);
00045 }
00046 }
00047
00048 #endif // vil_tile_images_h_