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

test_watershed.cpp

/* Copyright (c) 2001 A. Jalba */

#include <tip.h>

//   Example program for the watershed transform.
//
//   Usage:
//      test_watershed <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);
  }
 
  ByteImage im;
  IntImage out;

  // Read an image from the file specified by "argv[1]" and display it.     
  im.readImage(argv[1]);
  im.showImage();

  // Apply watershed transform on the input image using 4-connectivity and 
  // store the result in another image.
  Watershed(im, FOUR, out);
  out.showImage();

  char l;
  cin >> l;                                                                     
  
  im.closeWindow();
  out.closeWindow();
  return 1;
}