/* Copyright (c) 2001 C. Grigorescu */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tip.h> // Example program for the "Convolution" function. // // Usage: // test_convol <input_image> // int main(int argc, char *argv[]) { // Test for the correct number of arguments in the command line. if (argc != 2) { cout << "Usage: " << argv[0] << " <input_image>" << endl; exit(0); } FloatImage im1; im1.readImage(argv[1]); // Build a Gaussian kernel. FloatKernel k(im1.getWidth(),im1.getHeight(), "Gauss"); k.makeGauss(3.0); // Perform a couple of convolutions and time them. // At each iteration the support of the Gaussian // kernel is increased and the elapsed time printed out. Timer t; FloatImage res1(im1.getWidth(), im1.getHeight(), "Result"); t.Start(); float t1 = t.getTime(); float t2; for (int i=0;i<40;i++) { k.makeGauss(4*i+0.75); Convolution(im1, k, res1); t2 = t.getTime(); cout << t2 - t1 << endl; } // Show the result of the convolution and print the time needed // to execute all of them. res1.showImage(); t.Stop(); t.Print(); char c; cin >> c; }