/* Copyright (c) 2001 A. Jalba */ #include <tip.h> // Example program for edge detection methods. // // Usage: // test_edge <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 im, mag; vector< FloatImage > g(2); // Read an image from the file specified by "argv[1]" and display it. // Store the pixel values as floats. im.readImage(argv[1]); im.showImage(); char l; // Example of usage for GradientMap function. GradientMap(im, g[0], g[1]); g[0].showImage(); g[1].showImage(); cin >> l; g[0] = im; g[1] = im; // Example of usage for Normalize function. Normalize(g); cout << "Image statistics" << endl; cout << " Min: " << g[0].min() << endl; cout << " Max: " << g[0].max() << endl; cout << " Avg: " << g[0].avg() << endl; cout << " Std. dev.: " << g[0].dev() << endl << endl; g[0].showImage(); g[0] = im; g[1] = im; // Example of usage for Magnitude function. Magnitude(g, mag); mag.showImage(); cin >> l; // Find the edges in the input image using Prewitt's edge detector. EdgePrewitt(im, 1, mag); mag.setName("Prewitt"); mag.showImage(); // Find the edges in the input image using Sobel's edge detector. EdgeSobel(im, 1, g[0]); g[0].setName("Sobel"); g[0].showImage(); // Find the edges in the input image using Kirsch's edge detector. EdgeKirsch(im, g[1]); g[1].setName("Kirsch"); g[1].showImage(); cin >> l; im.closeWindow(); mag.closeWindow(); g[0].closeWindow(); g[1].closeWindow(); return 1; }