File: utility.cc

package info (click to toggle)
threeb 0.0~git20220106110332.a3144e0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,292 kB
  • sloc: cpp: 5,188; java: 1,741; ansic: 1,336; sh: 568; makefile: 62; awk: 26
file content (34 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "utility.h"
#include "debug.h"
#include <climits>
using namespace std;
using namespace CVD;

//! @cond Doxygen_Suppress
const std::vector<CVD::SubImage<float> > sub_images(const std::vector<CVD::Image<float> >& im, CVD::ImageRef pos, ImageRef size)
{
	assert_same_size(im);

	vector<SubImage<float> > subs;

	for(unsigned int i=0; i < im.size(); i++)
		subs.push_back(im[i].sub_image(pos, size));
	return subs;
}

pair<ImageRef, ImageRef> boundingbox(const vector<ImageRef> & all_spots)
{
	ImageRef lo(INT_MAX, INT_MAX), hi(INT_MIN, INT_MIN);
	for(unsigned int i=0; i < all_spots.size(); i++)
	{
		lo[0] = min(lo[0], all_spots[i][0]);
		lo[1] = min(lo[1], all_spots[i][1]);

		hi[0] = max(hi[0], all_spots[i][0]);
		hi[1] = max(hi[1], all_spots[i][1]);
	}

	return make_pair(lo, hi - lo + ImageRef(1,1));
}

//! @endcond