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                                                         const bool onlyActive)
00043 {
00044     const CPVector& cps = pano.getCtrlPoints();
00045     const UIntSet activeImgs(pano.getActiveImages());
00046     max = 0;
00047     min = 1000000;
00048     mean = 0;
00049     var = 0;
00050     
00051     int n=0;
00052     CPVector::const_iterator it;
00053     for (it = cps.begin() ; it != cps.end(); ++it) {
00054         if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr || (int)(*it).image2Nr != imgNr))
00055         {
00056             continue;
00057         }
00058         if (onlyActive && (!set_contains(activeImgs, it->image1Nr) || !set_contains(activeImgs, it->image2Nr)))
00059         {
00060             continue;
00061         };
00062         n++;
00063         double x = (*it).error;
00064         double delta = x - mean;
00065         mean += delta/n;
00066         var += delta*(x - mean);
00067         if (x > max) {
00068             max= (*it).error;
00069         }
00070         if (x < min) {
00071             min= (*it).error;
00072         }
00073     }
00074     var = var/(n-1);
00075 }    
00076 
00077 
00078 
00079 void CalculateCPStatisticsRadial::calcCtrlPntsRadiStats(const PanoramaData& pano,
00080                                                   double & min, double & max, double & mean, double & var,
00081                                                   double & q10, double & q90, 
00082                                                   const int& imgNr)
00083 {
00084     // calculate statistics about distance of control points from image center
00085     max = 0;
00086     min = 1000;
00087     mean = 0;
00088     var = 0;
00089     
00090     int n=0;
00091     CPVector::const_iterator it;
00092     const CPVector & cps = pano.getCtrlPoints();
00093     std::vector<double> radi;
00094     for (it = cps.begin() ; it != cps.end(); ++it) {
00095         if (imgNr >= 0 && ((int)(*it).image1Nr != imgNr || (int)(*it).image2Nr != imgNr))
00096         {
00097             continue;
00098         }
00099         const SrcPanoImage & img1 = pano.getImage((*it).image1Nr);
00100         const SrcPanoImage & img2 = pano.getImage((*it).image2Nr);
00101         const vigra::Size2D img1_size = img1.getSize();
00102         int w1 = img1_size.width();
00103         int h1 = img1_size.height();
00104         const vigra::Size2D img2_size = img2.getSize();
00105         int w2 = img2_size.width();
00106         int h2 = img2_size.height();
00107         
00108         // normalized distance to image center
00109         double x1 = ((*it).x1-(w1/2.0)) / (h1/2.0);
00110         double y1 = ((*it).y1-(h1/2.0)) / (h1/2.0);
00111         double x2 = ((*it).x2-(w2/2.0)) / (h2/2.0);
00112         double y2 = ((*it).y2-(h2/2.0)) / (h2/2.0);
00113         
00114         double r1 = sqrt(x1*x1 + y1*y1);
00115         radi.push_back(r1);
00116         double r2 = sqrt(x2*x2 + y2*y2);
00117         radi.push_back(r2);
00118         
00119         double x = r1;
00120         n++;
00121         double delta = x - mean;
00122         mean += delta/n;
00123         var += delta*(x - mean);
00124         if (x > max) {
00125             max= x;
00126         }
00127         if (x < min) {
00128             min= x;
00129         }
00130         
00131         x = r2;
00132         n++;
00133         delta = x - mean;
00134         mean += delta/n;
00135         var += delta*(x - mean);
00136         if (x > max) {
00137             max= x;
00138         }
00139         if (x < min) {
00140             min= x;
00141         }
00142     }
00143     var = var/(n-1);
00144     
00145     std::sort(radi.begin(), radi.end());
00146     q10 = radi[hugin_utils::floori(0.1*radi.size())];
00147     q90 = radi[hugin_utils::floori(0.9*radi.size())];
00148 }
00149     
00150     
00151 
00152 } // namespace

Generated on 30 Jun 2016 for Hugintrunk by  doxygen 1.4.7