Follow this link to skip to the main content

claraty::Resample_Op Class Reference
[Algorithms]

#include <resample_op.h>

Collaboration diagram for claraty::Resample_Op:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Resample_Op (Image< double >::Interpolation_t interpolation=Image< double >::BILINEAR)
 Resample_Op (int num_rows, int num_cols, Image< double >::Interpolation_t interpolation=Image< double >::BILINEAR)
 Resample_Op (double ratio, Image< double >::Interpolation_t interpolation=Image< double >::BILINEAR)
template<class TS, class TD>
void halfsample (Image< TS > src_image, Image< TD > &dest_image)
template<class TS, class TD>
void resample (Image< TS > src_image, Image< TD > &dest_image, int dest_num_rows, int dest_num_cols, typename Image< TS >::Interpolation_t interpolation=Image< TS >::BILINEAR)
template<class TS, class TD>
void resample (Image< TS > src_image, Image< TD > &dest_image, double ratio, typename Image< TS >::Interpolation_t interpolation=Image< TS >::BILINEAR)

Private Attributes

Image< double >::Interpolation_t _interpolation
bool _use_ratio
double _ratio
int _num_rows
int _num_cols

Detailed Description

INCOMPLETE: only does bilinear and ratio...fix!

Definition at line 41 of file resample_op.h.


Constructor & Destructor Documentation

claraty::Resample_Op::Resample_Op ( Image< double >::Interpolation_t  interpolation = Image< double >::BILINEAR  ) 

Definition at line 78 of file resample_op.h.

00078                                                                    :
00079   _use_ratio(true), _ratio(1.0), _interpolation(interpolation) {
00080 
00081 }

claraty::Resample_Op::Resample_Op ( int  num_rows,
int  num_cols,
Image< double >::Interpolation_t  interpolation = Image< double >::BILINEAR 
)

Definition at line 83 of file resample_op.h.

00084                                                                      :
00085   _use_ratio(false), _num_rows(num_rows), _num_cols(num_cols), _interpolation(interpolation) {
00086 
00087 }

claraty::Resample_Op::Resample_Op ( double  ratio,
Image< double >::Interpolation_t  interpolation = Image< double >::BILINEAR 
)

Definition at line 89 of file resample_op.h.

00090                                                                      :
00091   _use_ratio(true), _ratio(ratio), _interpolation(interpolation) {
00092 
00093 };


Member Function Documentation

template<class TS, class TD>
void claraty::Resample_Op::halfsample ( Image< TS >  src_image,
Image< TD > &  dest_image 
)

Definition at line 96 of file resample_op.h.

References claraty::N_2D_Array< T >::get_num_of_cols(), claraty::N_2D_Array< T >::get_num_of_rows(), and claraty::N_2D_Array< T >::resize().

00097                                                     {
00098 
00099   dest_image.resize((int)(src_image.get_num_of_rows()/2),
00100                     (int)(src_image.get_num_of_cols()/2));
00101 
00102   for(int r=0; r<dest_image.get_num_of_rows(); r++) {
00103     for(int c=0; c<dest_image.get_num_of_cols(); c++) {
00104 
00105       dest_image(r,c) = (TD) ((src_image(r*2, c*2) + src_image(r*2, c*2+1) + 
00106                                src_image(r*2+1, c*2) + src_image(r*2+1, c*2+1))/4);
00107     }
00108   }
00109                     
00110 }

Here is the call graph for this function:

template<class TS, class TD>
void claraty::Resample_Op::resample ( Image< TS >  src_image,
Image< TD > &  dest_image,
int  dest_num_rows,
int  dest_num_cols,
typename Image< TS >::Interpolation_t  interpolation = Image< TS >::BILINEAR 
)

template<class TS, class TD>
void claraty::Resample_Op::resample ( Image< TS >  src_image,
Image< TD > &  dest_image,
double  ratio,
typename Image< TS >::Interpolation_t  interpolation = Image< TS >::BILINEAR 
)

Definition at line 114 of file resample_op.h.

References claraty::N_2D_Array< T >::get_num_of_cols(), claraty::N_2D_Array< T >::get_num_of_rows(), claraty::Image< T >::pixel(), claraty::N_2D_Array< T >::resize(), and claraty::Image< T >::set_interpolation_type().

00117                                                                             {
00118   
00119   cout << "Resample_Op::resample: not tested" << endl;
00120   src_image.set_interpolation_type(interpolation);
00121 
00122   dest_image.resize((int)(src_image.get_num_of_rows()*ratio),
00123                     (int)(src_image.get_num_of_cols()*ratio));
00124 
00125   if (ratio==0.0)
00126     {
00127       cout << "Resample_Op::resample(): new image is 0x0\n";
00128       return;
00129     }
00130 
00131   ratio = 1.0/ratio;
00132 
00133   for(int r=0; r<dest_image.get_num_of_rows(); r++) {
00134     for(int c=0; c<dest_image.get_num_of_cols(); c++) {
00135 
00136       dest_image(r,c) = (TD) src_image.pixel((int)(c*ratio), (int)(r*ratio));
00137     }
00138   }
00139 
00140   /*
00141   const float K = 1.0F / ratio; 
00142   float f_x, f_y, a, b, pix1, pix2, pix3, pix4;
00143   int   i_x, i_y;
00144 
00145   int width = dest_image.get_num_of_cols();
00146   int height = dest_image.get_num_of_rows();
00147 
00148 
00149   for(int j=0; j<height; j++) {
00150 
00151     f_y = (float) j * K;
00152     i_y = (int) floor(f_y);
00153     a   = f_y - floor(f_y);
00154     
00155     
00156     for(int i=0; i<width; i++) {
00157       
00158       f_x = (float) i * K;
00159       i_x = (int) floor(f_x);
00160       b   = f_x - floor(f_x);
00161       
00162       pix1 = (float) src_image(i_y, i_x);
00163 
00164       if(i>=width)
00165         pix2 = pix1;
00166       else
00167         pix2 = (float) src_image(i_y, i_x+1);
00168 
00169       if(j>=height)
00170         pix3 = pix1;
00171       else
00172         pix3 = (float) src_image(i_y+1, i_x);
00173 
00174       if((j>=height)||(i>=width))
00175         pix4 = pix1;
00176       else
00177         pix4 = (float) src_image(i_y+1, i_x+1);
00178       
00179       dest_image(j,i) = (unsigned char) floor( (1.0F - a) * (((1.0F - b)
00180                          *pix1) + (b*pix2)) + a * (((1.0F - b)*pix3) + (b*pix4)) );
00181     }
00182   }
00183   */
00184 }

Here is the call graph for this function:


Member Data Documentation

Image<double>::Interpolation_t claraty::Resample_Op::_interpolation [private]

Definition at line 71 of file resample_op.h.

Definition at line 72 of file resample_op.h.

double claraty::Resample_Op::_ratio [private]

Definition at line 73 of file resample_op.h.

Definition at line 74 of file resample_op.h.

Definition at line 74 of file resample_op.h.


The documentation for this class was generated from the following file: