• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/utility/image_analysis/image_analysis_compute_feature_space_whitening.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_UTILITY_IMAGE_ANALYSIS_IMAGE_ANALYSIS_COMPUTE_FEATURE_SPACE_WHITENING_H
00002 #define OPENTISSUE_UTILITY_IMAGE_ANALYSIS_IMAGE_ANALYSIS_COMPUTE_FEATURE_SPACE_WHITENING_H
00003 //
00004 // OpenTissue Template Library
00005 // - A generic toolbox for physics-based modeling and simulation.
00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
00007 //
00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
00009 //
00010 #include <OpenTissue/configuration.h>
00011 
00012 #include <OpenTissue/utility/image_analysis/feature_space_pca.h>
00013 #include <OpenTissue/core/math/math_eigen_system_decomposition.h>
00014 #include <OpenTissue/core/math/math_is_finite.h>
00015 
00016 namespace OpenTissue
00017 {
00018   namespace image_analysis
00019   {
00029     template< typename feature_grid_type, typename matrix3x3_type, typename vector3_type >
00030     void compute_feature_space_whitening(feature_grid_type & feature_grid, matrix3x3_type & R, vector3_type & d  )
00031     {
00032       using std::sqrt;
00033 
00034       typedef typename feature_grid_type::index_iterator     feature_iterator;
00035 
00036       matrix3x3_type C;
00037       vector3_type mean;
00038       OpenTissue::image_analysis::feature_space_pca(feature_grid,mean,C);
00039 
00040       OpenTissue::math::eigen(C,R,d);
00041       //vector3_type e0 = vector3_type( R(0,0), R(1,0), R(2,0) );
00042       //vector3_type e1 = vector3_type( R(0,1), R(1,1), R(2,1) );
00043       //vector3_type e2 = vector3_type( R(0,2), R(1,2), R(2,2) );
00044       vector3_type inv_d2;
00045       inv_d2(0) = 1.0 / sqrt(d(0));
00046       inv_d2(1) = 1.0 / sqrt(d(1));
00047       inv_d2(2) = 1.0 / sqrt(d(2));
00048       feature_iterator fbegin = feature_grid.begin();
00049       feature_iterator fend   = feature_grid.end();
00050       feature_iterator f      = fbegin;
00051       for(; f!=fend;++f)
00052       {
00053         (*f) = R*((*f)-mean);
00054         (*f)(0) *= inv_d2(0);
00055         (*f)(1) *= inv_d2(1);
00056         (*f)(2) *= inv_d2(2);
00057         assert( is_finite( (*f)(0) ) || !"compute_feature_space_whitening(): NaN ");
00058         assert( is_finite( (*f)(1) ) || !"compute_feature_space_whitening(): NaN " );
00059         assert( is_finite( (*f)(2) ) || !"compute_feature_space_whitening(): NaN " );
00060       }
00061     }
00062 
00063   }// end namespace image_analysis
00064 
00065 } // namespace OpenTissue
00066 
00067 //  OPENTISSUE_UTILITY_IMAGE_ANALYSIS_IMAGE_ANALYSIS_COMPUTE_FEATURE_SPACE_WHITENING_H
00068 #endif

Generated on Thu Dec 1 2011 12:53:44 for HUMIM Tracker by  doxygen 1.7.1