CalculateCPStatistics.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00027 #include "CalculateCPStatistics.h"
00028 
00029 #include <math.h>
00030 #include <hugin_math/hugin_math.h>
00031 #include <panodata/PanoramaData.h>
00032 
00033 
00034 namespace HuginBase {
00035 
00036     
00037     
00038 void CalculateCPStatisticsError::calcCtrlPntsErrorStats(const PanoramaData& pano,
00039                                                         double & min, double & max, double & mean,
00040                                                         double & var,
00041                                                         const int& imgNr)
00042 {
00043     const CPVector& cps = pano.getCtrlPoints();
00044     
00045     max = 0;
00046     min = 1000000;
00047     mean = 0;
00048     var = 0;
00049     
00050     int n=0;
00051     CPVector::const_iterator it;
00052     for (it = cps.begin() ; it != cps.end(); it++) {
00053         if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr || (int)(*it).image2Nr != imgNr))
00054         {
00055             continue;
00056         }
00057         n++;
00058         double x = (*it).error;
00059         double delta = x - mean;
00060         mean += delta/n;
00061         var += delta*(x - mean);
00062         if (x > max) {
00063             max= (*it).error;
00064         }
00065         if (x < min) {
00066             min= (*it).error;
00067         }
00068     }
00069     var = var/(n-1);
00070 }    
00071 
00072 
00073 
00074 void CalculateCPStatisticsRadial::calcCtrlPntsRadiStats(const PanoramaData& pano,
00075                                                   double & min, double & max, double & mean, double & var,
00076                                                   double & q10, double & q90, 
00077                                                   const int& imgNr)
00078 {
00079     // calculate statistics about distance of control points from image center
00080     max = 0;
00081     min = 1000;
00082     mean = 0;
00083     var = 0;
00084     
00085     int n=0;
00086     CPVector::const_iterator it;
00087     const CPVector & cps = pano.getCtrlPoints();
00088     std::vector<double> radi;
00089     for (it = cps.begin() ; it != cps.end(); it++) {
00090         if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr || (int)(*it).image2Nr != imgNr))
00091         {
00092             continue;
00093         }
00094         const SrcPanoImage & img1 = pano.getImage((*it).image1Nr);
00095         const SrcPanoImage & img2 = pano.getImage((*it).image2Nr);
00096         const vigra::Size2D img1_size = img1.getSize();
00097         int w1 = img1_size.width();
00098         int h1 = img1_size.height();
00099         const vigra::Size2D img2_size = img2.getSize();
00100         int w2 = img2_size.width();
00101         int h2 = img2_size.height();
00102         
00103         // normalized distance to image center
00104         double x1 = ((*it).x1-(w1/2.0)) / (h1/2.0);
00105         double y1 = ((*it).y1-(h1/2.0)) / (h1/2.0);
00106         double x2 = ((*it).x2-(w2/2.0)) / (h2/2.0);
00107         double y2 = ((*it).y2-(h2/2.0)) / (h2/2.0);
00108         
00109         double r1 = sqrt(x1*x1 + y1*y1);
00110         radi.push_back(r1);
00111         double r2 = sqrt(x2*x2 + y2*y2);
00112         radi.push_back(r2);
00113         
00114         double x = r1;
00115         n++;
00116         double delta = x - mean;
00117         mean += delta/n;
00118         var += delta*(x - mean);
00119         if (x > max) {
00120             max= x;
00121         }
00122         if (x < min) {
00123             min= x;
00124         }
00125         
00126         x = r2;
00127         n++;
00128         delta = x - mean;
00129         mean += delta/n;
00130         var += delta*(x - mean);
00131         if (x > max) {
00132             max= x;
00133         }
00134         if (x < min) {
00135             min= x;
00136         }
00137     }
00138     var = var/(n-1);
00139     
00140     std::sort(radi.begin(), radi.end());
00141     q10 = radi[hugin_utils::floori(0.1*radi.size())];
00142     q90 = radi[hugin_utils::floori(0.9*radi.size())];
00143 }
00144     
00145     
00146 
00147 } // namespace

Generated on Wed Jul 16 01:25:37 2014 for Hugintrunk by  doxygen 1.3.9.1