Hugin trunk 0.1
Loading...
Searching...
No Matches
CalculateCPStatistics.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
28
29#include <math.h>
32
33
34namespace HuginBase {
35
36
37
39 double & min, double & max, double & mean,
40 double & var,
41 const int& imgNr,
42 const bool onlyActive,
43 const bool ignoreLineCp)
44{
45 const CPVector& cps = pano.getCtrlPoints();
47 max = 0;
48 min = 1000000;
49 mean = 0;
50 var = 0;
51
52 int n=0;
53 CPVector::const_iterator it;
54 for (it = cps.begin() ; it != cps.end(); ++it) {
55 if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr && (int)(*it).image2Nr != imgNr))
56 {
57 continue;
58 }
59 if (onlyActive && (!set_contains(activeImgs, it->image1Nr) || !set_contains(activeImgs, it->image2Nr)))
60 {
61 continue;
62 };
63 if (ignoreLineCp && it->mode != ControlPoint::X_Y)
64 {
65 continue;
66 };
67 n++;
68 double x = (*it).error;
69 double delta = x - mean;
70 mean += delta/n;
71 var += delta*(x - mean);
72 if (x > max) {
73 max= (*it).error;
74 }
75 if (x < min) {
76 min= (*it).error;
77 }
78 }
79 var = var/(n-1);
80}
81
82
83
85 double & min, double & max, double & mean, double & var,
86 double & q10, double & q90,
87 const int& imgNr)
88{
89 // calculate statistics about distance of control points from image center
90 max = 0;
91 min = 1000;
92 mean = 0;
93 var = 0;
94
95 int n=0;
96 CPVector::const_iterator it;
97 const CPVector & cps = pano.getCtrlPoints();
98 std::vector<double> radi;
99 for (it = cps.begin() ; it != cps.end(); ++it) {
100 if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr && (int)(*it).image2Nr != imgNr))
101 {
102 continue;
103 }
104 const SrcPanoImage & img1 = pano.getImage((*it).image1Nr);
105 const SrcPanoImage & img2 = pano.getImage((*it).image2Nr);
106 const vigra::Size2D img1_size = img1.getSize();
107 int w1 = img1_size.width();
108 int h1 = img1_size.height();
109 const vigra::Size2D img2_size = img2.getSize();
110 int w2 = img2_size.width();
111 int h2 = img2_size.height();
112
113 // normalized distance to image center
114 double x1 = ((*it).x1-(w1/2.0)) / (h1/2.0);
115 double y1 = ((*it).y1-(h1/2.0)) / (h1/2.0);
116 double x2 = ((*it).x2-(w2/2.0)) / (h2/2.0);
117 double y2 = ((*it).y2-(h2/2.0)) / (h2/2.0);
118
119 double r1 = sqrt(x1*x1 + y1*y1);
120 radi.push_back(r1);
121 double r2 = sqrt(x2*x2 + y2*y2);
122 radi.push_back(r2);
123
124 double x = r1;
125 n++;
126 double delta = x - mean;
127 mean += delta/n;
128 var += delta*(x - mean);
129 if (x > max) {
130 max= x;
131 }
132 if (x < min) {
133 min= x;
134 }
135
136 x = r2;
137 n++;
138 delta = x - mean;
139 mean += delta/n;
140 var += delta*(x - mean);
141 if (x > max) {
142 max= x;
143 }
144 if (x < min) {
145 min= x;
146 }
147 }
148 var = var/(n-1);
149
150 std::sort(radi.begin(), radi.end());
151 q10 = radi[hugin_utils::floori(0.1*radi.size())];
152 q90 = radi[hugin_utils::floori(0.9*radi.size())];
153}
154
155
156
157} // namespace
static void calcCtrlPntsErrorStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, const int &imgNr=-1, const bool onlyActive=false, const bool ignoreLineCp=false)
static void calcCtrlPntsRadiStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, double &q10, double &q90, const int &imgNr=-1)
Model for a panorama.
virtual UIntSet getActiveImages() const =0
get active images
virtual const CPVector & getCtrlPoints() const =0
get all control point of this Panorama
virtual const SrcPanoImage & getImage(std::size_t nr) const =0
get a panorama image, counting starts with 0
All variables of a source image.
misc math function & classes used by other parts of the program
mainly consists of wrapper around the pano tools library, to assist in ressource management and to pr...
Definition wxcms.cpp:39
std::vector< ControlPoint > CPVector
std::set< unsigned int > UIntSet
int floori(double x)
Definition hugin_math.h:65
bool set_contains(const _Container &c, const typename _Container::key_type &key)
Definition stl_utils.h:74
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition threshold.h:41