Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

test_edge.cpp

00001 /* Copyright (c) 2001 A. Jalba */
00002 
00003 #include <tip.h>
00004 
00005 //   Example program for edge detection methods.
00006 //
00007 //   Usage:
00008 //      test_edge <input_image>
00009 //
00010 
00011 int main(int argc, char **argv)
00012 {
00013   // Test for the correct number of arguments in the command line.
00014   if (argc != 2) {
00015     cout << "Usage: " << argv[0] << " <input_image>" << endl;
00016     exit(0);
00017   }
00018 
00019   FloatImage im, mag;
00020   vector< FloatImage > g(2);
00021   
00022   // Read an image from the file specified by "argv[1]" and display it.
00023   // Store the pixel values as floats.       
00024   im.readImage(argv[1]);
00025   im.showImage();
00026 
00027   char l;
00028 
00029   // Example of usage for GradientMap function.
00030   GradientMap(im, g[0], g[1]);
00031   g[0].showImage();
00032   g[1].showImage();
00033   cin >> l;
00034 
00035   g[0] = im;
00036   g[1] = im;
00037  
00038   // Example of usage for Normalize function.
00039   Normalize(g);
00040   cout << "Image statistics"  << endl;
00041   cout << " Min:       " << g[0].min() << endl;
00042   cout << " Max:       " << g[0].max() << endl;
00043   cout << " Avg:       " << g[0].avg() << endl;
00044   cout << " Std. dev.: " << g[0].dev() << endl << endl; 
00045   g[0].showImage();
00046   g[0] = im;
00047   g[1] = im;
00048 
00049   // Example of usage for Magnitude function.
00050   Magnitude(g, mag);  
00051   mag.showImage();
00052   cin >> l;
00053 
00054   // Find the edges in the input image using Prewitt's edge detector.
00055   EdgePrewitt(im, 1, mag);
00056   mag.setName("Prewitt");
00057   mag.showImage();
00058 
00059   // Find the edges in the input image using Sobel's edge detector.
00060   EdgeSobel(im, 1, g[0]);
00061   g[0].setName("Sobel");
00062   g[0].showImage();
00063 
00064   // Find the edges in the input image using Kirsch's edge detector.
00065   EdgeKirsch(im, g[1]);
00066   g[1].setName("Kirsch");
00067   g[1].showImage();
00068 
00069   cin >> l;
00070   im.closeWindow();
00071   mag.closeWindow();
00072   g[0].closeWindow();
00073   g[1].closeWindow();
00074   return 1;
00075 }