Go to the documentation of this file.00001 #ifndef OPENTISSUE_UTILITY_IMAGE_ANALYSIS_IMAGE_ANALYSIS_COMPUTE_FEATURE_SPACE_H
00002 #define OPENTISSUE_UTILITY_IMAGE_ANALYSIS_IMAGE_ANALYSIS_COMPUTE_FEATURE_SPACE_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/containers/grid/grid.h>
00013 #include <OpenTissue/core/containers/grid/util/grid_gradient_magnitude.h>
00014 #include <OpenTissue/core/containers/grid/util/grid_second_derivative.h>
00015 #include <OpenTissue/core/math/math_is_finite.h>
00016
00017
00018 namespace OpenTissue
00019 {
00020 namespace image_analysis
00021 {
00022
00030 template<
00031 typename image_type
00032 , typename feature_grid_type
00033 >
00034 void compute_feature_space(
00035 image_type const & U
00036 , feature_grid_type & feature_grid
00037 )
00038 {
00039 typedef typename feature_grid_type::math_types math_types;
00040 typedef OpenTissue::grid::Grid<double,math_types> real_grid_type;
00041 typedef typename real_grid_type::index_iterator image_iterator;
00042 typedef typename feature_grid_type::value_type vector3_type;
00043 typedef typename feature_grid_type::index_iterator feature_iterator;
00044
00045
00046
00047 real_grid_type real_U;
00048 real_U.create(U.min_coord(),U.max_coord(),U.I(),U.J(),U.K());
00049 std::copy(U.begin(),U.end(),real_U.begin());
00050
00051
00052 feature_grid.create(U.min_coord(),U.max_coord(),U.I(),U.J(),U.K());
00053
00054 feature_iterator fbegin = feature_grid.begin();
00055 feature_iterator fend = feature_grid.end();
00056 feature_iterator f = fbegin;
00057
00058 image_iterator ubegin = real_U.begin();
00059 image_iterator uend = real_U.end();
00060 image_iterator u = ubegin;
00061
00062 for(; u!=uend; ++u,++f)
00063 {
00064 (*f)(0) = *u;
00065 (*f)(1) = OpenTissue::grid::gradient_magnitude(u);
00066 (*f)(2) = OpenTissue::grid::second_derivative(u);
00067
00068 assert( is_finite( (*f)(0) ) || !"compute_feature_space(): NaN");
00069 assert( is_finite( (*f)(1) ) || !"compute_feature_space(): NaN" );
00070 assert( is_finite( (*f)(2) ) || !"compute_feature_space(): NaN" );
00071 }
00072 }
00073
00074 }
00075
00076 }
00077
00078
00079 #endif