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

test_conversion.cpp

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

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

//   Example program for the conversion facilities.
//
//   Usage:
//      test_conversion <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);
  }

  char l;

  // Read an image from the file specified by "argv[1]" and display it.
  Image< float > im1;
  im1.readImage(argv[1]);
  im1.showImage();

  IntImage im2(128,128,"Empty image");
  im2.showImage();
  cin >> l;

  // Conversion between Image< float > and IntImage.
  float2int(im1, im2);
  im2.showImage();

  // Conversion between Image< float > and Image< byte >.
  Image< byte > im3;
  float2byte(im1, im3);
  im3.showImage();

  // Conversion between Image< byte > and ByteImage.
  ByteImage im4;
  im4 = im3;
  im4.showImage();
  im3 = im4;

  cin >> l;
  // Close all displaying windows
  im1.closeWindow();
  im2.closeWindow();
  im3.closeWindow();
  im4.closeWindow();
  return(1);
}