Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

kino::convolve_filter< PixelType > Class Template Reference

A general-purpose one-dimensional convolve filter that operates as a finite state machine. More...

#include <kino_plugin_utility.h>

List of all members.

Public Member Functions

 convolve_filter ()
void push_weight (const double Weight)
unsigned int width ()
unsigned int neighbors ()
unsigned int middle ()
void push_value (const PixelType Value)
PixelType get_value ()
PixelType get_value (const unsigned int Start, const unsigned int End)

Private Types

typedef std::vector< double > weight_collection_type
typedef std::deque< PixelType > value_collection_type

Private Attributes

weight_collection_type m_weights
value_collection_type m_values
double m_scale


Detailed Description

template<typename PixelType>
class kino::convolve_filter< PixelType >

A general-purpose one-dimensional convolve filter that operates as a finite state machine.

Definition at line 91 of file kino_plugin_utility.h.


Member Typedef Documentation

template<typename PixelType>
typedef std::deque<PixelType> kino::convolve_filter< PixelType >::value_collection_type [private]
 

Definition at line 180 of file kino_plugin_utility.h.

template<typename PixelType>
typedef std::vector<double> kino::convolve_filter< PixelType >::weight_collection_type [private]
 

Definition at line 177 of file kino_plugin_utility.h.


Constructor & Destructor Documentation

template<typename PixelType>
kino::convolve_filter< PixelType >::convolve_filter  )  [inline]
 

Definition at line 94 of file kino_plugin_utility.h.

00094                       :
00095         m_scale(0)
00096     {
00097     }
    


Member Function Documentation

template<typename PixelType>
PixelType kino::convolve_filter< PixelType >::get_value const unsigned int  Start,
const unsigned int  End
[inline]
 

Definition at line 153 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_values, and kino::convolve_filter< PixelType >::m_weights.

00154     {
00155         double scale = std::accumulate(m_weights.begin() + Start, m_weights.begin() + End, 0.0);
00156         if(scale)
00157             scale = 1.0 / scale;    
00158     
00159         PixelType result;
00160         
00161         weight_collection_type::const_iterator weight = m_weights.begin() + Start;
00162         for(typename value_collection_type::iterator value = m_values.begin() + Start; value != m_values.begin() + End; ++value, ++weight)
00163             {
00164                 result.red += (value->red) * (*weight);
00165                 result.green += (value->green) * (*weight);
00166                 result.blue += (value->blue) * (*weight);
00167             }
00168             
00169         result.red *= scale;
00170         result.green *= scale;
00171         result.blue *= scale;
00172         
00173         return result;
00174     }

template<typename PixelType>
PixelType kino::convolve_filter< PixelType >::get_value  )  [inline]
 

Definition at line 134 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_scale, kino::convolve_filter< PixelType >::m_values, and kino::convolve_filter< PixelType >::m_weights.

00135     {
00136         PixelType result;
00137         
00138         weight_collection_type::const_iterator weight = m_weights.begin();
00139         for(typename value_collection_type::iterator value = m_values.begin(); value != m_values.end(); ++value, ++weight)
00140             {
00141                 result.red += (value->red) * (*weight);
00142                 result.green += (value->green) * (*weight);
00143                 result.blue += (value->blue) * (*weight);
00144             }
00145             
00146         result.red *= m_scale;
00147         result.green *= m_scale;
00148         result.blue *= m_scale;
00149         
00150         return result;
00151     }

template<typename PixelType>
unsigned int kino::convolve_filter< PixelType >::middle  )  [inline]
 

Definition at line 119 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_weights.

00120     {
00121         return m_weights.size() / 2;
00122     }

template<typename PixelType>
unsigned int kino::convolve_filter< PixelType >::neighbors  )  [inline]
 

Definition at line 114 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_weights.

00115     {
00116         return m_weights.size() / 2;
00117     }

template<typename PixelType>
void kino::convolve_filter< PixelType >::push_value const PixelType  Value  )  [inline]
 

Definition at line 124 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_values, and kino::convolve_filter< PixelType >::m_weights.

00125     {
00126         // Sanity checks ...
00127         assert(m_weights.size());
00128         assert(m_weights.size() == m_values.size());
00129         
00130         m_values.push_back(Value);
00131         m_values.pop_front();
00132     }

template<typename PixelType>
void kino::convolve_filter< PixelType >::push_weight const double  Weight  )  [inline]
 

Definition at line 99 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_scale, kino::convolve_filter< PixelType >::m_values, and kino::convolve_filter< PixelType >::m_weights.

00100     {
00101         m_weights.push_back(Weight);
00102         m_values.resize(m_weights.size());
00103         
00104         m_scale = std::accumulate(m_weights.begin(), m_weights.end(), 0.0);
00105         if(m_scale)
00106             m_scale = 1.0 / m_scale;
00107     }

template<typename PixelType>
unsigned int kino::convolve_filter< PixelType >::width  )  [inline]
 

Definition at line 109 of file kino_plugin_utility.h.

References kino::convolve_filter< PixelType >::m_weights.

00110     {
00111         return m_weights.size();
00112     }


Member Data Documentation

template<typename PixelType>
double kino::convolve_filter< PixelType >::m_scale [private]
 

Definition at line 183 of file kino_plugin_utility.h.

Referenced by kino::convolve_filter< PixelType >::get_value(), and kino::convolve_filter< PixelType >::push_weight().

template<typename PixelType>
value_collection_type kino::convolve_filter< PixelType >::m_values [private]
 

Definition at line 181 of file kino_plugin_utility.h.

Referenced by kino::convolve_filter< PixelType >::get_value(), kino::convolve_filter< PixelType >::push_value(), and kino::convolve_filter< PixelType >::push_weight().

template<typename PixelType>
weight_collection_type kino::convolve_filter< PixelType >::m_weights [private]
 

Definition at line 178 of file kino_plugin_utility.h.

Referenced by kino::convolve_filter< PixelType >::get_value(), kino::convolve_filter< PixelType >::middle(), kino::convolve_filter< PixelType >::neighbors(), kino::convolve_filter< PixelType >::push_value(), kino::convolve_filter< PixelType >::push_weight(), and kino::convolve_filter< PixelType >::width().


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 22:13:29 2007 for Kino by  doxygen 1.4.2