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

Generated on 23 Aug 2017 for Hugintrunk by  doxygen 1.4.7