del2g.c 1.8 KB

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