GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
del2g.c
Go to the documentation of this file.
1 /* Name: del2g
2
3  Created: Tue Mar 5 09:22:27 1985
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
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 */
#define G_malloc(n)
Definition: defs/gis.h:112
int del2g(double *img[2], int size, double w)
Definition: del2g.c:46
#define INVERSE
Definition: del2g.c:30
int getg(double, double *[2], int)
Definition: getg.c:16
void G_message(const char *,...) __attribute__((format(printf
float g
Definition: named_colr.c:8
#define _(str)
Definition: glocale.h:10
#define FORWARD
Definition: del2g.c:29
int fft(int, double *[2], int, int, int)
Fast Fourier Transform for two-dimensional array.
Definition: fft.c:127
int G_math_complex_mult(double *v1[2], int size1, double *v2[2], int size2, double *v3[2], int size3)
Multiply two complex vectors, point by point.
Definition: mult.c:23