libeblearn
/home/rex/ebltrunk/core/libeblearn/include/ebl_preprocessing.h
00001 /***************************************************************************
00002  *   Copyright (C) 2010 by Pierre Sermanet *
00003  *   pierre.sermanet@gmail.com *
00004  *   All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions are met:
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Redistribution under a license not approved by the Open Source
00014  *       Initiative (http://www.opensource.org) must display the
00015  *       following acknowledgement in all advertising material:
00016  *        This product includes software developed at the Courant
00017  *        Institute of Mathematical Sciences (http://cims.nyu.edu).
00018  *     * The names of the authors may not be used to endorse or promote products
00019  *       derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00023  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY
00025  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00026  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00028  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  ***************************************************************************/
00032 
00033 #ifndef EBL_PREPROCESSING_H_
00034 #define EBL_PREPROCESSING_H_
00035 
00036 #include "ebl_defines.h"
00037 #include "libidx.h"
00038 #include "ebl_arch.h"
00039 #include "ebl_march.h"
00040 #include "ebl_states.h"
00041 #include "ebl_normalization.h"
00042 #include "ebl_basic.h"
00043 
00044 namespace ebl {
00045 
00047   enum t_norm { WSTD_NORM = 0, /* local contrast normalization */
00048                 LAPLACIAN_NORM = 1 /* laplacian normalization */
00049   };
00050   
00052   // channels_module
00054   template <typename T, class Tstate = bbstate_idx<T> >
00055     class channels_module: public module_1_1<T,Tstate> {
00056   public:
00057     channels_module(bool global_norm = true, const char *name = "channels");
00058     virtual ~channels_module();
00059   protected:
00063     virtual void resize_output(Tstate &in, Tstate &out, int dim0 = -1);
00065     template <typename T1, class T2> friend class laplacian_pyramid_module;  
00066   protected:
00067     bool globnorm; 
00068   };
00069 
00071   // channorm_module
00073   template <typename T, class Tstate = bbstate_idx<T> >
00074     class channorm_module: public channels_module<T,Tstate> {
00075   public:
00084     channorm_module(idxdim &kerdim, bool mirror = true,
00085                     t_norm norm_mode = WSTD_NORM,
00086                     const char *name = "channorm", int nf = 1,
00087                     bool globnorm = true);
00089     virtual ~channorm_module();
00091     virtual void fprop(Tstate &in, Tstate &out) = 0;
00093     virtual channorm_module<T,Tstate>* copy() = 0;
00095     virtual std::string describe();
00097     module_1_1<T,Tstate>* new_norm(idxdim &normker, bool mirror, 
00098                                    t_norm norm_mode, int nf);
00099   protected:
00103     virtual void resize_output(Tstate &in, Tstate &out,
00104                                int dim0 = -1);
00105 
00106   protected:
00107     idxdim                      normker;        
00108     Tstate                      tmp;    
00109     module_1_1<T,Tstate>        *norm;  
00110     bool                        mirror; 
00111     t_norm                      norm_mode; 
00112   };
00113 
00115   // rgb_to_ynuv_module
00118   template <typename T, class Tstate = bbstate_idx<T> >
00119     class rgb_to_ynuv_module: public channorm_module<T,Tstate> {
00120   public:
00128     rgb_to_ynuv_module(idxdim &norm_kernel, bool mirror = true,
00129                        t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00131     virtual ~rgb_to_ynuv_module();
00133     virtual void fprop(Tstate &in, Tstate &out);
00135     virtual rgb_to_ynuv_module<T,Tstate>* copy();
00136   };
00137 
00139   // rgb_to_ynuvn_module
00142   template <typename T, class Tstate = bbstate_idx<T> >
00143     class rgb_to_ynuvn_module: public channorm_module<T,Tstate> {
00144   public:
00152     rgb_to_ynuvn_module(idxdim &norm_kernel, bool mirror = true,
00153                         t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00155     virtual ~rgb_to_ynuvn_module();
00157     virtual void fprop(Tstate &in, Tstate &out);
00159     virtual rgb_to_ynuvn_module<T,Tstate>* copy();
00160   protected:
00161     module_1_1<T,Tstate> *norm2; 
00162   };
00163 
00165   // rgb_to_ynunvn_module
00168   template <typename T, class Tstate = bbstate_idx<T> >
00169     class rgb_to_ynunvn_module: public channorm_module<T,Tstate> {
00170   public:
00178     rgb_to_ynunvn_module(idxdim &norm_kernel, bool mirror = true,
00179                         t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00181     virtual ~rgb_to_ynunvn_module();
00183     virtual void fprop(Tstate &in, Tstate &out);
00185     virtual rgb_to_ynunvn_module<T,Tstate>* copy();
00186   };
00187 
00189   // rgb_to_yuv_module
00191   template <typename T, class Tstate = bbstate_idx<T> >
00192     class rgb_to_yuv_module: public channels_module<T,Tstate> {
00193   public:
00195     rgb_to_yuv_module(bool globnorm = true);
00197     virtual ~rgb_to_yuv_module();
00199     virtual void fprop(Tstate &in, Tstate &out);
00201     virtual rgb_to_yuv_module<T,Tstate>* copy();
00202   };
00203 
00205   // rgb_to_yuvn_module
00208   template <typename T, class Tstate = bbstate_idx<T> >
00209     class rgb_to_yuvn_module: public channorm_module<T,Tstate> {
00210   public:
00218     rgb_to_yuvn_module(idxdim &norm_kernel, bool mirror = true,
00219                        t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00221     virtual ~rgb_to_yuvn_module();
00223     virtual void fprop(Tstate &in, Tstate &out);
00225     virtual rgb_to_yuvn_module<T,Tstate>* copy();
00226   };
00227 
00229   // rgb_to_rgbn_module
00232   template <typename T, class Tstate = bbstate_idx<T> >
00233     class rgb_to_rgbn_module: public channorm_module<T,Tstate> {
00234   public:
00242     rgb_to_rgbn_module(idxdim &norm_kernel, bool mirror = true,
00243                        t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00245     virtual ~rgb_to_rgbn_module();
00247     virtual void fprop(Tstate &in, Tstate &out);
00249     virtual rgb_to_rgbn_module<T,Tstate>* copy();
00250   };
00251 
00253   // rgb_to_y_module
00255   template <typename T, class Tstate = bbstate_idx<T> >
00256     class rgb_to_y_module: public channels_module<T,Tstate> {
00257   public:
00259     rgb_to_y_module(bool globnorm = true);
00261     virtual ~rgb_to_y_module();
00263     virtual void fprop(Tstate &in, Tstate &out);
00265     virtual rgb_to_y_module<T,Tstate>* copy();
00266   };
00267 
00269   // rgb_to_yn_module
00272   template <typename T, class Tstate = bbstate_idx<T> >
00273     class rgb_to_yn_module: public channorm_module<T,Tstate> {
00274   public:
00282     rgb_to_yn_module(idxdim &norm_kernel, bool mirror = true,
00283                      t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00285     virtual ~rgb_to_yn_module();
00287     virtual void fprop(Tstate &in, Tstate &out);
00289     virtual rgb_to_yn_module<T,Tstate>* copy();
00290   };
00291 
00293   // y_to_yp_module
00296   template <typename T, class Tstate = bbstate_idx<T> >
00297     class y_to_yp_module: public channorm_module<T,Tstate> {
00298   public:
00306     y_to_yp_module(idxdim &norm_kernel, bool mirror = true,
00307                    t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00309     virtual ~y_to_yp_module();
00311     virtual void fprop(Tstate &in, Tstate &out);
00313     virtual y_to_yp_module<T,Tstate>* copy();
00314   };
00315 
00317   // bgr_to_ypuv_module
00320   template <typename T, class Tstate = bbstate_idx<T> >
00321     class bgr_to_ypuv_module: public channorm_module<T,Tstate> {
00322   public:
00330     bgr_to_ypuv_module(idxdim &norm_kernel, bool mirror = true,
00331                        t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00333     virtual ~bgr_to_ypuv_module();
00335     virtual void fprop(Tstate &in, Tstate &out);
00337     virtual bgr_to_ypuv_module<T,Tstate>* copy();
00338   };
00339 
00341   // bgr_to_yp_module
00344   template <typename T, class Tstate = bbstate_idx<T> >
00345     class bgr_to_yp_module : public channorm_module<T,Tstate> {
00346   public:
00354     bgr_to_yp_module(idxdim &norm_kernel, bool mirror = true,
00355                      t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00357     virtual ~bgr_to_yp_module();
00359     virtual void fprop(Tstate &in, Tstate &out);
00361     virtual bgr_to_yp_module<T,Tstate>* copy();
00362   };
00363 
00365   // rgb_to_hp_module
00368   template <typename T, class Tstate = bbstate_idx<T> >
00369     class rgb_to_hp_module: public channorm_module<T,Tstate> {
00370   public:
00378     rgb_to_hp_module(idxdim &norm_kernel, bool mirror = true,
00379                      t_norm norm_mode = WSTD_NORM, bool globnorm = true);
00381     virtual ~rgb_to_hp_module();
00383     virtual void fprop(Tstate &in, Tstate &out);
00385     virtual rgb_to_hp_module<T,Tstate>* copy();
00386   };
00387 
00389   // resizepp_module
00397   template <typename T, class Tstate = bbstate_idx<T> >
00398     class resizepp_module: virtual public module_1_1<T,Tstate> {
00399   public:
00410     resizepp_module(idxdim &size, uint mode = MEAN_RESIZE,
00411                     module_1_1<T,Tstate> *pp = NULL,
00412                     bool own_pp = true, idxdim *zpad = NULL,
00413                     bool preserve_ratio = true);
00425     resizepp_module(uint mode = MEAN_RESIZE, module_1_1<T,Tstate> *pp = NULL,
00426                     bool own_pp = true, idxdim *zpad = NULL,
00427                     bool preserve_ratio = true);
00440     resizepp_module(double hratio, double wratio,
00441                     uint mode = MEAN_RESIZE, module_1_1<T,Tstate> *pp = NULL,
00442                     bool own_pp = true, idxdim *zpad = NULL,
00443                     bool preserve_ratio = true);
00445     virtual ~resizepp_module();
00447     void set_dimensions(intg height_, intg width_);
00450     void set_input_region(const rect<int> &inr);
00454     void set_output_region(const rect<int> &outr);
00457     void set_jitter(int h, int w, float s, float r);
00459     void set_scale_factor(double s);
00461     void set_scale_factor(double sh, double sw);
00463     void set_zpads(intg hpad, intg wpad);
00465     void set_zpad(idxdim &kernel);
00467     void set_zpad(midxdim &kernels);
00469     rect<int> get_original_bbox();
00471     rect<int> get_input_bbox();
00473     const vector<rect<int> >& get_input_bboxes();
00475     const vector<rect<int> >& get_original_bboxes();
00477     virtual rect<int> compute_regions(Tstate &in);
00479     virtual void remember_regions(intg outh, intg outw, rect<int> &r);
00481     virtual void set_display_range(T min, T max);
00483     virtual void get_display_range(T &min, T &max);
00484   
00485     // fprop methods ///////////////////////////////////////////////////////////
00486   
00488     virtual void fprop(Tstate &in, Tstate &out);
00490     virtual void fprop(Tstate &in, idx<T> &out);
00493     virtual void fprop(Tstate &in, midx<T> &out);
00494 
00496     virtual resizepp_module<T,Tstate>* copy();
00498     virtual std::string describe();
00500     virtual mstate<Tstate>* last_output();
00504     virtual void set_output_copy(mstate<Tstate> &out);
00508     virtual fidxdim bprop_size(const fidxdim &osize);
00512     virtual mfidxdim bprop_size(mfidxdim &osize);
00516     virtual mfidxdim get_msize();
00518     virtual uint nlayers();
00520     virtual void copy_outputs(mstate<Tstate> &out);
00521     
00522     // members /////////////////////////////////////////////////////////////////
00523   protected:
00524     module_1_1<T,Tstate> *pp;           
00525     bool                 own_pp;        
00526     idxdim               size;          
00527     intg                 height;        
00528     intg                 width;         
00529     Tstate               inpp, outpp;   
00530     idx<T>               tmp;           
00531     idx<T>               tmp2;          
00532     Tstate               tmp3;          
00533     rect<int>            input_bbox;    
00534     uint                 mode;          
00535     int                  input_mode;    
00536     rect<int>            inrect;        
00537     rect<int>            outrect;       
00538     bool                 inrect_set;    
00539     bool                 outrect_set;   
00540     idxdim               *dzpad;        
00541     zpad_module<T,Tstate> *zpad;        
00542     int                  hjitter;       
00543     int                  wjitter;       
00544     float                sjitter;       
00545     float                rjitter;       
00546     double               scale_hfactor;  
00547     double               scale_wfactor;  
00548     bool                 preserve_ratio;
00549     double               hratio;        
00550     double               wratio;        
00551     mstate<Tstate>       *lastout;      
00552     mstate<Tstate>       lout;          
00553     mfidxdim             msize;         
00554     mstate<Tstate>       *out_copy;     
00555     T                    display_min;   
00556     T                    display_max;   
00557     vector<rect<int> >   input_bboxes;  
00558     vector<rect<int> >   original_bboxes;
00559   };
00560 
00562   // fovea_module
00565   template <typename T, class Tstate = bbstate_idx<T> >
00566     class fovea_module
00567     : public resizepp_module<T,Tstate>, public s2m_module<T,Tstate> {
00568   public:
00581     // TODO: the comments dont match the constructor arguments anymore
00582   fovea_module(std::vector<double> &fovea, 
00583                midxdim &fovea_scales_size, idxdim &dsize, 
00584                bool boxscale = false, uint mode = MEAN_RESIZE, 
00585                module_1_1<T,Tstate> *pp = NULL,
00586                bool own_pp = true, idxdim *dzpad = NULL, 
00587                const char *name = "fovea");
00600     fovea_module(std::vector<double> &fovea, bool boxscale = false,
00601                  uint mode = MEAN_RESIZE,
00602                  module_1_1<T,Tstate> *pp = NULL,
00603                  bool own_pp = true, idxdim *dzpad = NULL,
00604                  const char *name = "fovea");
00605     virtual ~fovea_module();
00608     virtual void fprop(Tstate &in, Tstate &out);
00611     virtual void fprop(Tstate &in, midx<T> &out);
00614     virtual void fprop(Tstate &in, mstate<Tstate> &out);
00616     virtual void bprop(Tstate &in, mstate<Tstate> &out);
00618     virtual void bbprop(Tstate &in, mstate<Tstate> &out);
00620     virtual mfidxdim bprop_size(mfidxdim &osize);
00622     virtual std::string describe();
00624     const vector<rect<int> >& get_input_bboxes();
00626     const vector<rect<int> >& get_original_bboxes();
00628     virtual uint nlayers();
00629 
00630     // members ////////////////////////////////////////////////////////
00631   protected:
00632     std::vector<double> fovea; 
00633 
00634     midxdim fovea_scales_size; 
00635     bool boxscale; 
00636     std::vector<rect<int> > obboxes; 
00637     std::vector<rect<int> > ibboxes; 
00638   };
00639 
00641   // laplacian_pyramid_module
00643   template <typename T, class Tstate = bbstate_idx<T> >
00644     class laplacian_pyramid_module
00645     : public resizepp_module<T,Tstate>, public s2m_module<T,Tstate> {
00646   public:
00670     laplacian_pyramid_module(uint nscales, midxdim &sizes,
00671                              uint mode = MEAN_RESIZE, 
00672                              module_1_1<T,Tstate> *pp = NULL,
00673                              bool own_pp = true, idxdim *dzpad = NULL,
00674                              bool global_norm = true, bool local_norm = false,
00675                              bool local_norm2 = false, bool color_norm = false,
00676                              bool cnorm_across = true,
00677                              bool keep_aspect_ratio = true,
00678                              const char *name = "laplacian_pyramid");
00702     laplacian_pyramid_module(uint nscales, idxdim &kerdims,
00703                              midxdim &sizes, uint mode = MEAN_RESIZE, 
00704                              module_1_1<T,Tstate> *pp = NULL,
00705                              bool own_pp = true, idxdim *dzpad = NULL, 
00706                              bool global_norm = true, bool local_norm = false,
00707                              bool local_norm2 = false, bool color_norm = false,
00708                              bool cnorm_across = true,
00709                              bool keep_aspect_ratio = true,
00710                              const char *name = "laplacian_pyramid");
00734     laplacian_pyramid_module(uint nscales, midxdim &kerdims,
00735                              midxdim &sizes, uint mode = MEAN_RESIZE, 
00736                              module_1_1<T,Tstate> *pp = NULL,
00737                              bool own_pp = true, idxdim *dzpad = NULL, 
00738                              bool global_norm = true, bool local_norm = false,
00739                              bool local_norm2 = false, bool color_norm = false,
00740                              bool cnorm_across = true,
00741                              bool keep_aspect_ratio = true,
00742                              const char *name = "laplacian_pyramid");
00764     laplacian_pyramid_module(uint nscales,
00765                              uint mode = MEAN_RESIZE,
00766                              module_1_1<T,Tstate> *pp = NULL,
00767                              bool own_pp = true, idxdim *dzpad = NULL,
00768                              bool global_norm = true, bool local_norm = false,
00769                              bool local_norm2 = false, bool color_norm = false,
00770                              bool cnorm_across = true,
00771                              bool keep_aspect_ratio = true,
00772                              const char *name = "laplacian_pyramid");
00773     virtual ~laplacian_pyramid_module();
00775     virtual void init();
00776 
00777     // processing //////////////////////////////////////////////////////////////
00778   
00780     virtual void fprop(Tstate &in, Tstate &out);
00783     virtual void fprop(Tstate &in, mstate<Tstate> &out);
00786     virtual void fprop(Tstate &in, midx<T> &out);
00788     virtual void bprop(Tstate &in, mstate<Tstate> &out);
00790     virtual void bbprop(Tstate &in, mstate<Tstate> &out);
00791 
00792     // size propagation ////////////////////////////////////////////////////////
00793   
00798     virtual mfidxdim fprop_size(mfidxdim &isize);
00802     virtual mfidxdim bprop_size(mfidxdim &osize);
00804     virtual std::string describe();
00806     virtual uint nlayers();
00809     virtual void set_scalings(vector<float> &scalings);
00810 
00811     // internal methods ////////////////////////////////////////////////////////
00812   protected:
00814     void resize(idx<T> &im, idxdim &tgt, rect<int> &inr, rect<int> &outr);
00817     void blur(idx<T> &filter, idx<T> &in, idx<T> &out, rect<int> &roi);
00823     idx<T> highpass(idx<T> &in, idx<T> &blurred, idxdim &tgt, rect<int> &inr, 
00824                     bool first);
00828     void subsample(idx<T> &in, idx<T> &out, rect<int> &inr);
00834     void normalize_globally(idx<T> &in); //, rect<int> &roi);
00836     void normalize_intensity_globally(idx<T> &in); // , rect<int> &roi);
00838     void normalize_color_globally(idx<T> &in); // , rect<int> &roi);
00840     void normalize_globally2(idx<T> &in); // , rect<int> &roi);
00841   
00842     // members ////////////////////////////////////////////////////////
00843   protected:
00844     uint nscales; 
00845     uint iscale; 
00846     vector<float> scalings; 
00847     midxdim sizes; 
00848     midxdim kerdims; 
00849     idx<T> burt; 
00850     vector<idx<T> > filters; 
00851     vector<zpad_module<T,Tstate>*> pads; 
00852     bool use_pad; 
00853     bool global_norm; 
00854     bool local_norm; 
00855     bool local_norm2; 
00856     bool color_lnorm; 
00857     bool cnorm_across; 
00858     bool keep_aspect_ratio; 
00859     bool mirror; 
00860     idx<T> blurred; 
00861     idx<T> blurred_high; 
00862     idx<T> high0; 
00863     Tstate padded; 
00864     vector<layers<T,Tstate>*> norms; 
00865     vector<layers<T,Tstate>*> cnorms; 
00866     midx<T> tmp;
00867     mstate<Tstate> tmp2, tmp3;
00868     Tstate inpp, outpp; 
00869     midx<T> outs; 
00870     mstate<Tstate> zpad_out; 
00871     using resizepp_module<T,Tstate>::zpad;
00872     using resizepp_module<T,Tstate>::input_bboxes;
00873     using resizepp_module<T,Tstate>::original_bboxes;
00874     bool burt_filtering_only; 
00875   };
00876 
00878   // mschan_module
00883   template <typename T, class Tstate = bbstate_idx<T> >
00884     class mschan_module : public s2m_module<T,Tstate> {
00885   public:
00889     mschan_module(uint nstates, const char *name = "mschan");
00890     virtual ~mschan_module();
00892     virtual void fprop(Tstate &in, mstate<Tstate> &out);
00894     virtual void bprop(Tstate &in, mstate<Tstate> &out);
00896     virtual void bbprop(Tstate &in, mstate<Tstate> &out);
00897   };
00898 
00900   // resize_module
00903   template <typename T, class Tstate = bbstate_idx<T> >
00904     class resize_module: public module_1_1<T,Tstate> {
00905   public:
00919     resize_module(double hratio, double wratio, uint mode = BILINEAR_RESIZE,
00920                   uint hzpad = 0, uint wzpad = 0, bool preserve_ratio = false);
00932     resize_module(intg height, intg width, uint mode = MEAN_RESIZE,
00933                   uint hzpad = 0, uint wzpad = 0, bool preserve_ratio = false);
00944     resize_module(uint mode = MEAN_RESIZE, uint hzpad = 0, uint wzpad = 0,
00945                   bool preserve_ratio = false);
00947     virtual ~resize_module();
00949     void set_dimensions(intg height, intg width);
00952     void set_input_region(const rect<int> &inr);
00956     void set_output_region(const rect<int> &outr);
00958     void set_jitter(int h, int w, float s, float r);
00960     void set_zpads(intg hpad, intg wpad);
00962     virtual void fprop(Tstate &in, Tstate &out);
00964     virtual void bprop(Tstate &in, Tstate &out);
00966     virtual void bbprop(Tstate &in, Tstate &out);
00969     rect<int> get_original_bbox();
00971     virtual resize_module<T,Tstate>* copy();
00973     virtual std::string describe();
00974     
00975     // members ////////////////////////////////////////////////////////
00976   private:
00977     intg                 height;        
00978     intg                 width;         
00979     idx<T>               tmp;           
00980     idx<T>               tmp2;          
00981     Tstate               tmp3;          
00982     rect<int>            original_bbox; 
00983     uint                 mode;          
00984     int                  input_mode;    
00985     rect<int>            inrect;        
00986     rect<int>            outrect;       
00987     bool                 inrect_set;    
00988     bool                 outrect_set;   
00989     uint                 hzpad;         
00990     uint                 wzpad;         
00991     zpad_module<T,Tstate> *zpad;        
00992     int                  hjitter;       
00993     int                  wjitter;       
00994     float                sjitter;       
00995     float                rjitter;       
00996     bool                 preserve_ratio;
00997     double               hratio;        
00998     double               wratio;        
00999   };
01000 
01001   // jitter ////////////////////////////////////////////////////////////////////
01002 
01004   template<typename T, class Tstate = bbstate_idx<T> >
01005     class EXPORT jitter_module : public module_1_1<T,Tstate,Tstate> {
01006   public:
01008     jitter_module(const char *name = "jitter_module");
01010     virtual ~jitter_module();
01011 
01012     // jitters setting /////////////////////////////////////////////////////////
01015     void set_translations(vector<int> &v);
01017     void set_rotations(vector<float> &v);
01020     void set_scalings(vector<float> &v);
01023     void set_shears(vector<float> &v);
01026     void set_elastics(vector<float> &v);
01029     void set_padding(vector<uint> &pads);
01030   
01031     // multi-state inputs and outputs //////////////////////////////////////////
01032     virtual void fprop(Tstate &in, Tstate &out);
01033     virtual void bprop(Tstate &in, Tstate &out);
01034     virtual void bbprop(Tstate &in, Tstate &out);
01036     virtual std::string describe();
01038     virtual jitter_module<T,Tstate>* copy();
01039   protected:
01040     // variable members ////////////////////////////////////////////////////////
01041     int th0, th1, tw0, tw1; 
01042     float deg0, deg1; 
01043     float sh0, sh1, sw0, sw1; 
01044     float shh0, shh1, shw0, shw1; 
01045     uint elsz0, elsz1; 
01046     float elcoeff0, elcoeff1; 
01047     zpad_module<T,Tstate> *zp; 
01048     Tstate tmp;
01049   };
01050 
01051 } // namespace ebl {
01052 
01053 #include "ebl_preprocessing.hpp"
01054 
01055 #endif /* EBL_PREPROCESSING_H_ */