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

test_localop.cpp

00001 /* Copyright (c) 2001 S.E. Grigorescu */
00002 
00003 #include <iostream.h>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <tip.h>
00007 
00008 //   Example program for the "LocalOp" function.
00009 //
00010 //   Usage:
00011 //      test_localop <input_image>
00012 //
00013 
00014 int main(int argc, char *argv[])
00015 {
00016   // Test for the correct number of arguments in the command line.
00017   if (argc != 2) {
00018     cout << "Usage: " << argv[0] << " <input_image>" << endl;
00019     exit(0);
00020   }
00021                          
00022   // Read an image from the file specified by "argv[1]" and display it.
00023   Image< float > img, im1;
00024   im1.readImage(argv[1]);
00025   im1.setName("test_image");
00026   im1.showImage();
00027   char l;
00028 
00029   // Apply a local averaging filter on a neighborhood of 16X16.
00030   LocalOp(im1, "mean", 16, img);
00031   img.setName("mean");
00032   img.showImage();
00033   cin >> l;
00034   
00035   // Apply a local median filter on a neighborhood of 17X17.
00036   LocalOp(im1, "median", 17, img);
00037   img.setName("median");
00038   img.showImage();
00039   cin >> l;
00040 
00041   // Compute the local standard deviation on a neighborhood of 15X17.
00042   LocalOp(im1, "stdev", 15, 17, img);
00043   img.setName("stdev");
00044   img.showImage();
00045   cin >> l;
00046 
00047   // Compute the local variance on a neighborhood of 15X15.
00048   LocalOp(im1, "var", 15, img);
00049   img.setName("var");
00050   img.showImage();
00051   cin >> l;
00052 
00053   // Compute the local minimum on a neighborhood of 5X5 in place.
00054   img = im1;
00055   LocalOp(img, "min", 5);
00056   img.setName("min");
00057   img.showImage();
00058   cin >> l;
00059 
00060   // Compute the local maximum on a neighborhood of 5X7 in place.
00061   img = im1;
00062   LocalOp(img, "max", 5, 7);
00063   img.setName("max");
00064   img.showImage();
00065   cin >> l;
00066 
00067   return(1);
00068 }