00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "utility.h"
00021 #include "debug.h"
00022 #include <climits>
00023 using namespace std;
00024 using namespace CVD;
00025
00026
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