38 #ifndef __IMAGE_PYRAMID_HPP__
39 #define __IMAGE_PYRAMID_HPP__
41 #include <cuv/tensor_ops/tensor_ops.hpp>
54 template <
class __matrix_type>
79 inline int dim(){
return m_dim;}
80 inline unsigned int base_h(){
return m_base_height;}
81 inline unsigned int base_w(){
return m_base_width;}
82 inline unsigned int depth(){
return m_matrices.size();}
90 template<
class __arg_matrix_type>
91 void build(
const __arg_matrix_type& src,
const unsigned int interleaved_channels){
92 typedef typename __arg_matrix_type::value_type argval_type;
93 typedef typename __arg_matrix_type::memory_space_type argmemspace_type;
94 typedef typename __arg_matrix_type::index_type argindex_type;
100 if( src.shape()[0] == m_base_height*m_dim
101 && src.shape()[1] == m_base_width
106 else if( interleaved_channels == 4
110 argca_type cpy(src,4);
114 else if(src.shape()[0] > m_base_height*m_dim
115 && src.shape()[1] > m_base_width
118 for(
int i=0;i<m_dim;i++){
119 const __arg_matrix_type view(indices[
index_range(0,src.shape()[0]/m_dim)][
index_range(0,src.shape()[1])],(argval_type*)src.ptr());
120 argca_type cpy(view);
132 for(
int i=1;i<m_matrices.size();i++){
133 for(
int d=0;d<m_dim;d++){
135 argca_type cpy(*srcview);
145 std::vector<matrix_type*> m_matrices;
147 unsigned int m_base_width;
148 unsigned int m_base_height;
151 template <
class __matrix_type>
152 typename image_pyramid<__matrix_type>::matrix_type*
158 unsigned int w = mat.shape()[1];
159 unsigned int h = mat.shape()[0];
163 template <
class __matrix_type>
167 matrix_type& mat = *m_matrices[depth];
171 template <
class __matrix_type>
173 :m_base_height(img_h)
177 for(
unsigned int i=0;i<m_matrices.size();i++)
178 delete m_matrices[i];
180 for(
unsigned int i=0; i<
depth;i++){
182 m_matrices.push_back(
new matrix_type(extents[img_h*m_dim][img_w]));
183 img_h=ceil(img_h/2.f);
184 img_w=ceil(img_w/2.f);
196 template<
class T,
class S,
class I>
200 const unsigned int interleaved_channels
202 template<
class T,
class S,
class I>
203 void gaussian_pyramid_upsample(
208 template<
class TDest,
class T,
class S,
class I>
209 void get_pixel_classes(
215 template<
class T,
class S,
class I>