TuttleOFX
1
|
00001 #ifndef _TERRY_NUMERIC_MATRIX_HPP_ 00002 #define _TERRY_NUMERIC_MATRIX_HPP_ 00003 00004 #include <terry/numeric/assign.hpp> 00005 00006 #include <boost/numeric/ublas/matrix.hpp> 00007 00008 namespace terry { 00009 namespace numeric { 00010 00011 template <typename PixelRef, typename Matrix, typename PixelR = PixelRef> // models pixel concept 00012 struct pixel_matrix33_multiply_t 00013 { 00014 typedef typename channel_type<PixelR>::type ChannelR; 00015 const Matrix _matrix; 00016 00017 pixel_matrix33_multiply_t( const Matrix& m ) 00018 : _matrix(m) 00019 {} 00020 00021 GIL_FORCEINLINE 00022 PixelR operator ( ) ( const PixelRef & p ) const 00023 { 00024 PixelR result; 00025 pixel_assigns_t<PixelRef, PixelR>()( p, result ); 00026 //color_convert( p, result ); 00027 result[0] = _matrix( 0, 0 ) * p[0] + _matrix( 0, 1 ) * p[1] + _matrix( 0, 2 ) * p[2]; 00028 result[1] = _matrix( 1, 0 ) * p[0] + _matrix( 1, 1 ) * p[1] + _matrix( 1, 2 ) * p[2]; 00029 result[2] = _matrix( 2, 0 ) * p[0] + _matrix( 2, 1 ) * p[1] + _matrix( 2, 2 ) * p[2]; 00030 return result; 00031 } 00032 }; 00033 00034 00035 } 00036 } 00037 00038 #endif