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

test_translate.cpp

00001 /* Copyright (c) 2001 S.E. Grigorescu */
00002 
00003 #include <iostream.h>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 #include <string.h>
00007 #include <tip.h>
00008 
00009 //   Example program for the "Translate" function.
00010 //
00011 //   Usage:
00012 //      test_translate <input_image>
00013 //
00014 
00015 int main(int argc, char *argv[])
00016 {
00017   // Test for the correct number of arguments in the command line.
00018   if (argc != 2) {
00019     cout << "Usage: " << argv[0] << " <input_image>" << endl;
00020     exit(0);
00021   }
00022 
00023   // Read an image from the file specified by "argv[1]" and display it.
00024   Image< int > im1; 
00025   im1.readImage(argv[1]);
00026   im1.setName("test_image");
00027   im1.showImage();
00028  
00029   // Translate the input image 57.5 pixels to the right and 40 pixels upwards and 
00030   // store the result in a second image.
00031   Image< int > im2; 
00032   Translate(im1, 57.5, -40, im2);
00033   im2.setName("test_image_1");
00034   im2.showImage();
00035 
00036   // Translate in place the input image 64 pixels to the left and 95.2 pixels downwards.
00037   Image< int > im3 = im1;
00038   Translate(im3, -64, 95.2);
00039   im3.setName("test_image_2");
00040   im3.showImage(); 
00041 
00042   char l;
00043   cin >> l;
00044   im1.closeWindow();
00045   im2.closeWindow();
00046   im3.closeWindow();        
00047   return(1);
00048 }