//*************************************************************************** #include <stdio.h> #include <stdlib.h> #include <math.h> #include <malloc.h> #include "matrix.h" #include "gabor.h" #include "image.h" //*************************************************************************** void main(int argc, char **argv) { int hei, wid, side, scale, orientation, flag, s, n; double Ul, Uh; /* --------------------------- Example -------------------------------- scale = 3, orientation = 4, Uh (highest spatial frequency) = 0.4, Ul (lowest spatial frequency) = 0.1, flag (removing the DC term) = 0 (False), side (filter dimension = (2*side+1)*(2*side+1)) = 60 ----------------------------------------------------------------------- */ scale = 3; orientation = 4; Ul = 0.1; Uh = 0.4; flag = 0; side = 60; if (argc != 2) { cerr << "Usage: " << argv[0] << " <ppm_image_file>" << endl; exit(-1); } GrayImage origImage; origImage.ReadFromFile(argv[1]); hei = origImage.height; wid = origImage.width; Matrix img(hei, wid); origImage.WriteToMatrix(&img); origImage.ReadFromMatrix(&img); origImage.WriteToFile("Orig.dat"); /* ------ print out the Gabor filters (intensity plot) ----------------- */ /* Matrix Gr(2*side+1, 2*side+1), Gi(2*side+1, 2*side+1); Matrix Gabor_r((2*side+1)*scale, (2*side+1)*orientation), Gabor_i((2*side+1)*scale, (2*side+1)*orientation); for (int s = 0; s < scale; s++) for (int n = 0; n < orientation; n++) { Gabor(&Gr, &Gi, s+1, n+1, Ul, Uh, scale, orientation, flag); MatCopy(&Gabor_r, &Gr, s*(2*side+1), n*(2*side+1), 0, 0, 2*side, 2*side); MatCopy(&Gabor_i, &Gi, s*(2*side+1), n*(2*side+1), 0, 0, 2*side, 2*side); } GrayImage image; image.ReadFromMatrix(&Gabor_r); image.WriteToFile("GaborR.dat"); image.ReadFromMatrix(&Gabor_i); image.WriteToFile("GaborI.dat"); */ /* ------ Save the Gabor filtered outputs ----------------- */ Matrix F_r(hei*scale, wid*orientation), F_i(hei*scale, wid*orientation); GaborFilteredImg(&F_r, &F_i, &img, side, Ul, Uh, scale, orientation, flag); GrayImage image2; image2.ReadFromMatrix(&F_r); image2.WriteToFile("OutputR.dat"); image2.ReadFromMatrix(&F_i); image2.WriteToFile("OutputI.dat"); } //***************************************************************************