Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

gaussian_2D.h

Go to the documentation of this file.
00001 
00040 #ifndef __GAUSSIAN_2D__
00041 #define __GAUSSIAN_2D__
00042 
00043 #include <math.h>
00044 
00045 #include "base_2D.h"
00046 
00053 namespace Function_2D{
00054 
00055 /*
00056   ############
00057   # Gaussian #
00058   ############
00059 */
00060 
00061   
00063   class Gaussian:public Base_2D{
00064 
00065   public:
00066     inline Gaussian::Gaussian(const real_type in_offset_x = 0,
00067                               const real_type in_offset_y = 0,
00068                               const real_type in_scale_x = 1,
00069                               const real_type in_scale_y = 1,
00070                               const real_type in_rotation_angle = 0,
00071                               const real_type out_offset = 0,
00072                               const real_type out_scale = 1);
00073 
00074     static inline real_type base_value(const real_type x,
00075                                        const real_type y);
00076 
00077   protected:
00078     virtual inline real_type base_value_proxy(const real_type x,
00079                                               const real_type y) const;
00080 
00081 
00082   
00083   };
00084 
00085 
00086 
00087 
00088   
00089 /*
00090   #######################
00091   # Normalized gaussian #
00092   #######################
00093 */
00094 
00095 
00097   class Normalized_gaussian:public Filter_interface_2D{
00098 
00099   public:
00100     inline Normalized_gaussian(const real_type center_x = 0,
00101                                const real_type center_y = 0,
00102                                const real_type sigma_x = 1,
00103                                const real_type sigma_y = 1,
00104                                const real_type orientation_angle = 0);
00105 
00106   protected:
00107     virtual inline real_type base_value_proxy(const real_type x,
00108                                               const real_type y) const;
00109   };
00110 
00111 
00112 
00113 /*
00114   ###########################
00115   # FFT normalized gaussian #
00116   ###########################
00117 */
00118 
00119 
00121   class FFT_normalized_gaussian:public Filter_interface_2D{
00122 
00123   public:
00124     inline FFT_normalized_gaussian(const real_type center_x = 0,
00125                                    const real_type center_y = 0,
00126                                    const real_type sigma_x = 1,
00127                                    const real_type sigma_y = 1,
00128                                    const real_type orientation_angle = 0);
00129 
00130   protected:
00131     virtual inline real_type base_value_proxy(const real_type x,
00132                                               const real_type y) const;
00133   };
00134 
00135 
00136 
00137   
00138 /*
00139   #########################
00140   # Gaussian x-derivative #
00141   #########################
00142 */
00143 
00144 
00146   class Gaussian_x_derivative:public Base_2D{
00147 
00148   public:
00149     inline Gaussian_x_derivative::
00150     Gaussian_x_derivative(const real_type in_offset_x = 0,
00151                           const real_type in_offset_y = 0,
00152                           const real_type in_scale_x = 1,
00153                           const real_type in_scale_y = 1,
00154                           const real_type in_rotation_angle = 0,
00155                           const real_type out_offset = 0,
00156                           const real_type out_scale = 1);
00157 
00158     static inline real_type base_value(const real_type x,
00159                                        const real_type y);
00160 
00161   protected:
00162     virtual inline real_type base_value_proxy(const real_type x,
00163                                               const real_type y) const;
00164 
00165 
00166   
00167   };
00168 
00169 
00170   
00171 /*
00172   ####################################
00173   # Normalized gaussian x-derivative #
00174   ####################################
00175 */
00176 
00177 
00179   class Normalized_gaussian_x_derivative:public Filter_interface_2D{
00180 
00181   public:
00182     inline Normalized_gaussian_x_derivative(const real_type center_x = 0,
00183                                             const real_type center_y = 0,
00184                                             const real_type sigma_x = 1,
00185                                             const real_type sigma_y = 1,
00186                                             const real_type orientation_angle = 0);
00187 
00188   protected:
00189     virtual inline real_type base_value_proxy(const real_type x,
00190                                               const real_type y) const;
00191   };
00192 
00193 
00194 
00195 
00196 
00197   
00198 /*
00199   #########################
00200   # Gaussian y-derivative #
00201   #########################
00202 */
00203 
00204 
00206   class Gaussian_y_derivative:public Base_2D{
00207 
00208   public:
00209     inline Gaussian_y_derivative::
00210     Gaussian_y_derivative(const real_type in_offset_x = 0,
00211                           const real_type in_offset_y = 0,
00212                           const real_type in_scale_x = 1,
00213                           const real_type in_scale_y = 1,
00214                           const real_type in_rotation_angle = 0,
00215                           const real_type out_offset = 0,
00216                           const real_type out_scale = 1);
00217 
00218     static inline real_type base_value(const real_type x,
00219                                        const real_type y);
00220 
00221   protected:
00222     virtual inline real_type base_value_proxy(const real_type x,
00223                                               const real_type y) const;
00224 
00225 
00226   
00227   };
00228 
00229 
00230   
00231 /*
00232   ####################################
00233   # Normalized gaussian y-derivative #
00234   ####################################
00235 */
00236 
00237 
00239   class Normalized_gaussian_y_derivative:public Filter_interface_2D{
00240 
00241   public:
00242     inline Normalized_gaussian_y_derivative(const real_type center_x = 0,
00243                                             const real_type center_y = 0,
00244                                             const real_type sigma_x = 1,
00245                                             const real_type sigma_y = 1,
00246                                             const real_type orientation_angle=0);
00247 
00248   protected:
00249     virtual inline real_type base_value_proxy(const real_type x,
00250                                               const real_type y) const;
00251   };
00252 
00253 
00254 
00255   
00256 /*
00257   #############################
00258   # Gaussian x-2nd-derivative #
00259   #############################
00260 */
00261 
00262 
00264   class Gaussian_x_2nd_derivative:public Base_2D{
00265 
00266   public:
00267     inline Gaussian_x_2nd_derivative::
00268     Gaussian_x_2nd_derivative(const real_type in_offset_x = 0,
00269                               const real_type in_offset_y = 0,
00270                               const real_type in_scale_x = 1,
00271                               const real_type in_scale_y = 1,
00272                               const real_type in_rotation_angle = 0,
00273                               const real_type out_offset = 0,
00274                               const real_type out_scale = 1);
00275     
00276     static inline real_type base_value(const real_type x,
00277                                        const real_type y);
00278 
00279   protected:
00280     virtual inline real_type base_value_proxy(const real_type x,
00281                                               const real_type y) const;
00282 
00283 
00284   
00285   };
00286 
00287 
00288   
00289 /*
00290   ########################################
00291   # Normalized gaussian x-2nd_derivative #
00292   ########################################
00293 */
00294 
00295 
00297   class Normalized_gaussian_x_2nd_derivative:public Filter_interface_2D{
00298 
00299   public:
00300     inline Normalized_gaussian_x_2nd_derivative(const real_type center_x = 0,
00301                                                 const real_type center_y = 0,
00302                                                 const real_type sigma_x = 1,
00303                                                 const real_type sigma_y = 1,
00304                                                 const real_type orientation_angle = 0);
00305     
00306   protected:
00307     virtual inline real_type base_value_proxy(const real_type x,
00308                                               const real_type y) const;
00309   };
00310 
00311 
00312 
00313 
00314 
00315 
00316 
00317   
00326 
00327   class Gaussian_step:public Base_2D{
00328 
00329   public:
00330     inline Gaussian_step::Gaussian_step(const real_type in_offset_x = 0,
00331                                         const real_type in_offset_y = 0,
00332                                         const real_type in_scale_x = 1,
00333                                         const real_type in_scale_y = 1,
00334                                         const real_type in_rotation_angle = 0,
00335                                         const real_type out_offset = 0,
00336                                         const real_type out_scale = 1);
00337 
00338     static inline real_type base_value(const real_type x,
00339                                        const real_type y);
00340 
00341   protected:
00342     virtual inline real_type base_value_proxy(const real_type x,
00343                                               const real_type y) const;
00344 
00345 
00346   
00347   };
00348 
00349 
00350 
00351 
00352   
00353 /*
00354   ############################
00355   # Normalized gaussian step #
00356   ############################
00357 */
00358 
00359 
00361   class Normalized_gaussian_step:public Filter_interface_2D{
00362 
00363   public:
00364     inline Normalized_gaussian_step(const real_type center_x = 0,
00365                                     const real_type center_y = 0,
00366                                     const real_type sigma_x = 1,
00367                                     const real_type sigma_y = 1,
00368                                     const real_type orientation_angle = 0);
00369 
00370   protected:
00371     virtual inline real_type base_value_proxy(const real_type x,
00372                                               const real_type y) const;
00373   };
00374 
00375 
00376   
00377 
00378 /*
00379   ###########################################################
00380   ###########################################################
00381   ###########################################################
00382   ##############                               ##############
00383   ##############  I M P L E M E N T A T I O N  ##############
00384   ##############                               ##############
00385   ###########################################################
00386   ###########################################################
00387   ###########################################################
00388 */
00389 
00390 
00391 
00392 
00393 /*
00394   ############
00395   # Gaussian #
00396   ############
00397 */
00398   
00399   Gaussian::Gaussian(const real_type in_offset_x,
00400                      const real_type in_offset_y,
00401                      const real_type in_scale_x,
00402                      const real_type in_scale_y,
00403                      const real_type in_rotation_angle,
00404                      const real_type out_offset,
00405                      const real_type out_scale):
00406     Base_2D(in_offset_x,in_offset_y,
00407             in_scale_x,in_scale_y,
00408             in_rotation_angle,
00409             out_offset,out_scale){}
00410 
00411   Gaussian::real_type Gaussian::base_value_proxy(const real_type x,
00412                                                  const real_type y) const{
00413 
00414     return Gaussian::base_value(x,y);
00415   }
00416 
00417   Gaussian::real_type Gaussian::base_value(const real_type x,
00418                                            const real_type y){
00419     return exp(-(x*x + y*y));
00420   }
00421 
00422 
00423 
00424   
00425 /*
00426   #######################
00427   # Normalized gaussian #
00428   #######################
00429 */
00430 
00431   Normalized_gaussian::
00432   Normalized_gaussian(const real_type center_x,
00433                       const real_type center_y,
00434                       const real_type sigma_x,
00435                       const real_type sigma_y,
00436                       const real_type orientation_angle):
00437     Filter_interface_2D(center_x,center_y,
00438                         sigma_x,sigma_y,
00439                         M_SQRT1_2,M_SQRT1_2,
00440                         orientation_angle,
00441                         0.5/M_PI){}
00442 
00443   Normalized_gaussian::real_type
00444   Normalized_gaussian::base_value_proxy(const real_type x,
00445                                         const real_type y) const{
00446 
00447     return Gaussian::base_value(x,y);
00448   }
00449 
00450 
00451 
00452 /*
00453   ###########################
00454   # FFT normalized gaussian #
00455   ###########################
00456 */
00457 
00458   FFT_normalized_gaussian::
00459   FFT_normalized_gaussian(const real_type center_x,
00460                           const real_type center_y,
00461                           const real_type sigma_x,
00462                           const real_type sigma_y,
00463                           const real_type orientation_angle):
00464     Filter_interface_2D(center_x,center_y,
00465                         sigma_x,sigma_y,
00466                         M_SQRT2*M_PI,M_SQRT2*M_PI,
00467                         orientation_angle,
00468                         1){
00469     output_scale = 1;
00470   }
00471 
00472   FFT_normalized_gaussian::real_type
00473   FFT_normalized_gaussian::base_value_proxy(const real_type x,
00474                                             const real_type y) const{
00475     
00476     FFT_normalized_gaussian* proxy = const_cast<FFT_normalized_gaussian*>(this);
00477     proxy->output_scale = 1;
00478     return Gaussian::base_value(x,y);
00479   }
00480 
00481 
00482 
00483   /*
00484     #########################
00485     # Gaussian x-derivative #
00486     #########################
00487   */
00488 
00489   Gaussian_x_derivative::Gaussian_x_derivative(const real_type in_offset_x,
00490                                                const real_type in_offset_y,
00491                                                const real_type in_scale_x,
00492                                                const real_type in_scale_y,
00493                                                const real_type in_rotation_angle,
00494                                                const real_type out_offset,
00495                                                const real_type out_scale):
00496     Base_2D(in_offset_x,in_offset_y,
00497             in_scale_x,in_scale_y,
00498             in_rotation_angle,
00499             out_offset,out_scale){}
00500 
00501   Gaussian_x_derivative::real_type
00502   Gaussian_x_derivative::base_value_proxy(const real_type x,
00503                                           const real_type y) const{
00504     
00505     return Gaussian_x_derivative::base_value(x,y);
00506   }
00507 
00508   Gaussian_x_derivative::real_type
00509   Gaussian_x_derivative::base_value(const real_type x,
00510                                     const real_type y){
00511     
00512     return -2*x*exp(-(x*x + y*y));
00513   }
00514 
00515 
00516   
00517 
00518   /*
00519     ####################################
00520     # Normalized gaussian x-derivative #
00521     ####################################
00522   */
00523   
00524   Normalized_gaussian_x_derivative::
00525   Normalized_gaussian_x_derivative(const real_type center_x,
00526                                    const real_type center_y,
00527                                    const real_type sigma_x,
00528                                    const real_type sigma_y,
00529                                    const real_type orientation_angle):
00530     Filter_interface_2D(center_x,center_y,
00531                         sigma_x,sigma_y,
00532                         M_SQRT1_2,M_SQRT1_2,
00533                         orientation_angle,
00534                         0.5/M_PI){}
00535 
00536   Normalized_gaussian_x_derivative::real_type
00537   Normalized_gaussian_x_derivative::base_value_proxy(const real_type x,
00538                                                      const real_type y) const{
00539 
00540     return Gaussian_x_derivative::base_value(x,y)*input_scale_x;
00541   }
00542 
00543   
00544 
00545   /*
00546     #########################
00547     # Gaussian y-derivative #
00548     #########################
00549   */
00550 
00551   Gaussian_y_derivative::Gaussian_y_derivative(const real_type in_offset_x,
00552                                                const real_type in_offset_y,
00553                                                const real_type in_scale_x,
00554                                                const real_type in_scale_y,
00555                                                const real_type in_rotation_angle,
00556                                                const real_type out_offset,
00557                                                const real_type out_scale):
00558     Base_2D(in_offset_x,in_offset_y,
00559             in_scale_x,in_scale_y,
00560             in_rotation_angle,
00561             out_offset,out_scale){}
00562 
00563   Gaussian_y_derivative::real_type
00564   Gaussian_y_derivative::base_value_proxy(const real_type x,
00565                                           const real_type y) const{
00566     
00567     return Gaussian_y_derivative::base_value(x,y);
00568   }
00569 
00570   Gaussian_y_derivative::real_type
00571   Gaussian_y_derivative::base_value(const real_type x,
00572                                     const real_type y){
00573     
00574     return -2*y*exp(-(x*x + y*y));
00575   }
00576 
00577 
00578   
00579 
00580   /*
00581     ####################################
00582     # Normalized gaussian y-derivative #
00583     ####################################
00584   */
00585   
00586   Normalized_gaussian_y_derivative::
00587   Normalized_gaussian_y_derivative(const real_type center_x,
00588                                    const real_type center_y,
00589                                    const real_type sigma_x,
00590                                    const real_type sigma_y,
00591                                    const real_type orientation_angle):
00592     Filter_interface_2D(center_x,center_y,
00593                         sigma_x,sigma_y,
00594                         M_SQRT1_2,M_SQRT1_2,
00595                         orientation_angle,
00596                         0.5/M_PI){}
00597 
00598   Normalized_gaussian_y_derivative::real_type
00599   Normalized_gaussian_y_derivative::base_value_proxy(const real_type x,
00600                                                      const real_type y) const{
00601     
00602     return Gaussian_y_derivative::base_value(x,y)*input_scale_x;
00603   }
00604 
00605 
00606 
00607   /*
00608     #############################
00609     # Gaussian x-2nd_derivative #
00610     #############################
00611   */
00612 
00613   Gaussian_x_2nd_derivative::Gaussian_x_2nd_derivative(const real_type in_offset_x,
00614                                                const real_type in_offset_y,
00615                                                const real_type in_scale_x,
00616                                                const real_type in_scale_y,
00617                                                const real_type in_rotation_angle,
00618                                                const real_type out_offset,
00619                                                const real_type out_scale):
00620     Base_2D(in_offset_x,in_offset_y,
00621             in_scale_x,in_scale_y,
00622             in_rotation_angle,
00623             out_offset,out_scale){}
00624 
00625   Gaussian_x_2nd_derivative::real_type
00626   Gaussian_x_2nd_derivative::base_value_proxy(const real_type x,
00627                                           const real_type y) const{
00628     
00629     return Gaussian_x_2nd_derivative::base_value(x,y);
00630   }
00631 
00632   Gaussian_x_2nd_derivative::real_type
00633   Gaussian_x_2nd_derivative::base_value(const real_type x,
00634                                         const real_type y){
00635     
00636     return (4*x*x-2)*exp(-(x*x + y*y));
00637   }
00638 
00639 
00640   
00641   
00642 
00643   /*
00644     ########################################
00645     # Normalized gaussian x-2nd_derivative #
00646     ########################################
00647   */
00648   
00649   Normalized_gaussian_x_2nd_derivative::
00650   Normalized_gaussian_x_2nd_derivative(const real_type center_x,
00651                                        const real_type center_y,
00652                                        const real_type sigma_x,
00653                                        const real_type sigma_y,
00654                                        const real_type orientation_angle):
00655     Filter_interface_2D(center_x,center_y,
00656                         sigma_x,sigma_y,
00657                         M_SQRT1_2,M_SQRT1_2,
00658                         orientation_angle,
00659                         0.5/M_PI){}
00660 
00661   Normalized_gaussian_x_2nd_derivative::real_type
00662   Normalized_gaussian_x_2nd_derivative::base_value_proxy(const real_type x,
00663                                                          const real_type y) const{
00664     
00665     return Gaussian_x_2nd_derivative::base_value(x,y)*input_scale_x*input_scale_x;
00666   }
00667 
00668   
00669   
00670 
00671   /*
00672     #################
00673     # Gaussian step #
00674     #################
00675   */
00676   
00677   Gaussian_step::Gaussian_step(const real_type in_offset_x,
00678                                const real_type in_offset_y,
00679                                const real_type in_scale_x,
00680                                const real_type in_scale_y,
00681                                const real_type in_rotation_angle,
00682                                const real_type out_offset,
00683                                const real_type out_scale):
00684     Base_2D(in_offset_x,in_offset_y,
00685             in_scale_x,in_scale_y,
00686             in_rotation_angle,
00687             out_offset,out_scale){}
00688 
00689   Gaussian_step::real_type
00690   Gaussian_step::base_value_proxy(const real_type x,
00691                                   const real_type y) const{
00692     
00693     return Gaussian_step::base_value(x,y);
00694   }
00695 
00696   Gaussian_step::real_type Gaussian_step::base_value(const real_type x,
00697                                                      const real_type y){
00698 
00699     const real_type s = (x==0) ? 0 : ((x>0) ? 1 : -1);
00700     return s*exp(-(x*x + y*y));
00701   }
00702 
00703 
00704 
00705   
00706 /*
00707   ############################
00708   # Normalized gaussian step #
00709   ############################
00710 */
00711 
00712   Normalized_gaussian_step::
00713   Normalized_gaussian_step(const real_type center_x,
00714                            const real_type center_y,
00715                            const real_type sigma_x,
00716                            const real_type sigma_y,
00717                            const real_type orientation_angle):
00718     Filter_interface_2D(center_x,center_y,
00719                         sigma_x,sigma_y,
00720                         M_SQRT1_2,M_SQRT1_2,
00721                         orientation_angle,
00722                         0.5/M_PI){}
00723 
00724   Normalized_gaussian_step::real_type
00725   Normalized_gaussian_step::base_value_proxy(const real_type x,
00726                                              const real_type y) const{
00727     
00728     return Gaussian_step::base_value(x,y);
00729   }
00730 
00731 
00732 }
00733   
00734 #endif

Generated on Fri Aug 20 12:08:01 2004 by doxygen1.2.18