1 /*      Name:   del2g
2 
3    Created:        Tue Mar  5 09:22:27 1985
4    Last modified:  Tue May  6 21:21:41 1986
5 
6    Purpose:        Take the Laplacian of a gaussian of the image.
7 
8    Details:        This routine does a convolution of the Marr-Hildreth operator
9    (Laplacian of a gaussian) with the given image, and returns
10    the result.  Uses the array processor.  Does the convolution
11    in the frequency domain (ie, multiplies the fourier transforms
12    of the image and the filter together, and takes the inverse
13    transform).
14 
15    Author:         Bill Hoff,2-114C,8645,3563478 (hoff) at uicsl
16  */
17 
18 
19 #include <grass/config.h>
20 
21 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H)
22 
23 #include <stdio.h>
24 #include <grass/gmath.h>
25 #include <grass/gis.h>
26 #include <grass/glocale.h>
27 
28 
29 #define FORWARD  1
30 #define INVERSE -1
31 #define SCALE    1
32 #define NOSCALE  0
33 
34 
35 /*!
36  * \fn int del2g (double *img[2], int size, double w)
37  *
38  * \brief
39  *
40  * \param img
41  * \param size
42  * \param w
43  * \return int
44  */
45 
del2g(double * img[2],int size,double w)46 int del2g(double *img[2], int size, double w)
47 {
48     double *g[2];		/* the filter function */
49 
50     G_message(_("    taking FFT of image..."));
51     fft(FORWARD, img, size * size, size, size);
52 
53     g[0] = (double *)G_malloc(size * size * sizeof(double));
54     g[1] = (double *)G_malloc(size * size * sizeof(double));
55 
56     G_message(_("    computing del**2 g..."));
57     getg(w, g, size);
58 
59     G_message(_("    taking FFT of del**2 g..."));
60     fft(FORWARD, g, size * size, size, size);
61 
62     /* multiply the complex vectors img and g, each of length size*size */
63     G_message(_("    multiplying transforms..."));
64     G_math_complex_mult(img, size * size, g, size * size, img, size * size);
65 
66     G_message(_("    taking inverse FFT..."));
67     fft(INVERSE, img, size * size, size, size);
68 
69     return 0;
70 }
71 
72 #endif /* HAVE_FFTW */
73