ThreeB 1.1
utility.cc
Go to the documentation of this file.
00001 #include "utility.h"
00002 #include "debug.h"
00003 #include <climits>
00004 using namespace std;
00005 using namespace CVD;
00006 
00007 //! @cond Doxygen_Suppress
00008 const std::vector<CVD::SubImage<float> > sub_images(const std::vector<CVD::Image<float> >& im, CVD::ImageRef pos, ImageRef size)
00009 {
00010     assert_same_size(im);
00011 
00012     vector<SubImage<float> > subs;
00013 
00014     for(unsigned int i=0; i < im.size(); i++)
00015         subs.push_back(im[i].sub_image(pos, size));
00016     return subs;
00017 }
00018 
00019 pair<ImageRef, ImageRef> boundingbox(const vector<ImageRef> & all_spots)
00020 {
00021     ImageRef lo(INT_MAX, INT_MAX), hi(INT_MIN, INT_MIN);
00022     for(unsigned int i=0; i < all_spots.size(); i++)
00023     {
00024         lo[0] = min(lo[0], all_spots[i][0]);
00025         lo[1] = min(lo[1], all_spots[i][1]);
00026 
00027         hi[0] = max(hi[0], all_spots[i][0]);
00028         hi[1] = max(hi[1], all_spots[i][1]);
00029     }
00030 
00031     return make_pair(lo, hi - lo + ImageRef(1,1));
00032 }
00033 
00034 //! @endcond