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

test_translate.cpp

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

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

//   Example program for the "Translate" function.
//
//   Usage:
//      test_translate <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< int > im1; 
  im1.readImage(argv[1]);
  im1.setName("test_image");
  im1.showImage();
 
  // Translate the input image 57.5 pixels to the right and 40 pixels upwards and 
  // store the result in a second image.
  Image< int > im2; 
  Translate(im1, 57.5, -40, im2);
  im2.setName("test_image_1");
  im2.showImage();

  // Translate in place the input image 64 pixels to the left and 95.2 pixels downwards.
  Image< int > im3 = im1;
  Translate(im3, -64, 95.2);
  im3.setName("test_image_2");
  im3.showImage(); 

  char l;
  cin >> l;
  im1.closeWindow();
  im2.closeWindow();
  im3.closeWindow();        
  return(1);
}