/* Copyright (c) 2001 C. Grigorescu */ #include <stdio.h> #include <stdlib.h> #include <tip.h> // Example program for the "Kernel" class. // // Usage: // test_kernel <sigma> <aspect> <orientation> // int main(int argc, char *argv[]) { // Test for the correct number of arguments. if (argc != 4) { cout << "Usage: " << argv[0] << " <sigma> <aspect> <orientation> " << endl; exit(0); } // Create a kernel of size 32x32 with the name "gabor.pgm". FloatKernel k1(32,32, "gabor.pgm"); float sigma = atof(argv[1]); float aspect = atof(argv[2]); float orientation = atof(argv[3]); // Generate a discrete Gabor function. k1.makeGabor(sigma, aspect, 0.0, 10.0, 0.0); // Save current kernel as an image. k1.writeKernel(); // Display the kernel as an image. k1.showKernel(); // Generate an oriented Gaussian and display it. FloatKernel k2(128, 128, "Test Gauss"); k2.makeGauss(sigma,aspect,orientation); k2.showKernel(); // Generate a triangular pulse of size 32x32, // set the maximum amplitude to "sigma" and the support to 12 pixels. FloatKernel tri(32,32,"Triang. pulse"); tri.makeRectangularPulse(sigma,12); tri.makeTriangularPulse(sigma,12); // Write the kernel coefficients to the file "test.coeff" in ASCII // format and with the comment "Triangular pulse: supp. = 12". tri.writeKernelCoeffs("test.coeff", "Triangular pulse: supp. = 12"); tri.showKernel(); // Read the kernel coefficients from the ASCII file and display it. FloatKernel re("Read"); re.readKernelCoeffs("test.coeff"); re.showKernel(); char l; cin >> l; return(1); }