ThreeB 1.1
utility.cc
Go to the documentation of this file.
00001 /*
00002     This file is part of B-cubed.
00003 
00004     Copyright (C) 2009, 2010, 2011, Edward Rosten and Susan Cox
00005 
00006     B-cubed is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 3.0 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License     
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>
00018 */
00019 
00020 #include "utility.h"
00021 #include "debug.h"
00022 #include <climits>
00023 using namespace std;
00024 using namespace CVD;
00025 
00026 //! @cond Doxygen_Suppress
00027 const std::vector<CVD::SubImage<float> > sub_images(const std::vector<CVD::Image<float> >& im, CVD::ImageRef pos, ImageRef size)
00028 {
00029     assert_same_size(im);
00030 
00031     vector<SubImage<float> > subs;
00032 
00033     for(unsigned int i=0; i < im.size(); i++)
00034         subs.push_back(im[i].sub_image(pos, size));
00035     return subs;
00036 }
00037 
00038 pair<ImageRef, ImageRef> boundingbox(const vector<ImageRef> & all_spots)
00039 {
00040     ImageRef lo(INT_MAX, INT_MAX), hi(INT_MIN, INT_MIN);
00041     for(unsigned int i=0; i < all_spots.size(); i++)
00042     {
00043         lo[0] = min(lo[0], all_spots[i][0]);
00044         lo[1] = min(lo[1], all_spots[i][1]);
00045 
00046         hi[0] = max(hi[0], all_spots[i][0]);
00047         hi[1] = max(hi[1], all_spots[i][1]);
00048     }
00049 
00050     return make_pair(lo, hi - lo + ImageRef(1,1));
00051 }
00052 
00053 //! @endcond