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

test_localop.cpp

/* Copyright (c) 2001 S.E. Grigorescu */

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <tip.h>

//   Example program for the "LocalOp" function.
//
//   Usage:
//      test_localop <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);
  }
                         
  // Read an image from the file specified by "argv[1]" and display it.
  Image< float > img, im1;
  im1.readImage(argv[1]);
  im1.setName("test_image");
  im1.showImage();
  char l;

  // Apply a local averaging filter on a neighborhood of 16X16.
  LocalOp(im1, "mean", 16, img);
  img.setName("mean");
  img.showImage();
  cin >> l;
  
  // Apply a local median filter on a neighborhood of 17X17.
  LocalOp(im1, "median", 17, img);
  img.setName("median");
  img.showImage();
  cin >> l;

  // Compute the local standard deviation on a neighborhood of 15X17.
  LocalOp(im1, "stdev", 15, 17, img);
  img.setName("stdev");
  img.showImage();
  cin >> l;

  // Compute the local variance on a neighborhood of 15X15.
  LocalOp(im1, "var", 15, img);
  img.setName("var");
  img.showImage();
  cin >> l;

  // Compute the local minimum on a neighborhood of 5X5 in place.
  img = im1;
  LocalOp(img, "min", 5);
  img.setName("min");
  img.showImage();
  cin >> l;

  // Compute the local maximum on a neighborhood of 5X7 in place.
  img = im1;
  LocalOp(img, "max", 5, 7);
  img.setName("max");
  img.showImage();
  cin >> l;

  return(1);
}