GRASS Programmer's Manual
6.4.2(2012)
|
00001 /* Name: del2g 00002 00003 Created: Tue Mar 5 09:22:27 1985 00004 Last modified: Tue May 6 21:21:41 1986 00005 00006 Purpose: Take the Laplacian of a gaussian of the image. 00007 00008 Details: This routine does a convolution of the Marr-Hildreth operator 00009 (Laplacian of a gaussian) with the given image, and returns 00010 the result. Uses the array processor. Does the convolution 00011 in the frequency domain (ie, multiplies the fourier transforms 00012 of the image and the filter together, and takes the inverse 00013 transform). 00014 00015 Author: Bill Hoff,2-114C,8645,3563478 (hoff) at uicsl 00016 */ 00017 00018 00019 #include <grass/config.h> 00020 00021 #if defined(HAVE_FFTW_H) || defined(HAVE_DFFTW_H) || defined(HAVE_FFTW3_H) 00022 00023 #include <stdio.h> 00024 #include <grass/gmath.h> 00025 #include <grass/gis.h> 00026 #include <grass/glocale.h> 00027 00028 00029 #define FORWARD 1 00030 #define INVERSE -1 00031 #define SCALE 1 00032 #define NOSCALE 0 00033 00034 00046 int del2g(double *img[2], int size, double w) 00047 { 00048 double *g[2]; /* the filter function */ 00049 00050 G_message(_(" taking FFT of image...")); 00051 fft(FORWARD, img, size * size, size, size); 00052 00053 g[0] = (double *)G_malloc(size * size * sizeof(double)); 00054 g[1] = (double *)G_malloc(size * size * sizeof(double)); 00055 00056 G_message(_(" computing del**2 g...")); 00057 getg(w, g, size); 00058 00059 G_message(_(" taking FFT of del**2 g...")); 00060 fft(FORWARD, g, size * size, size, size); 00061 00062 /* multiply the complex vectors img and g, each of length size*size */ 00063 G_message(_(" multiplying transforms...")); 00064 mult(img, size * size, g, size * size, img, size * size); 00065 00066 G_message(_(" taking inverse FFT...")); 00067 fft(INVERSE, img, size * size, size, size); 00068 00069 return 0; 00070 } 00071 00072 #endif /* HAVE_FFTW */