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

test_zoom.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 "Zoom" function.
00010 //
00011 //   Usage:
00012 //      test_zoom <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< float > im1; 
00025   im1.readImage(argv[1]);
00026   im1.setName("test_image");
00027   im1.showImage();
00028  
00029   // Zoom out the input image 2.5 times along the x-axis and 1.3 times along the y-axis and 
00030   // store the result in a second image.
00031   Image< float > im2; 
00032   Zoom(im1, 2.5, 1.3, im2);
00033   im2.setName("test_image_1");
00034   im2.showImage();
00035  
00036   // Zoom in the input image 2.5 times along the x-axis and 1.3 times along the y-axis and 
00037   // store the result in a second image.
00038   Image< float > im3; 
00039   Zoom(im1, 1/2.5, 1/1.3, im3);
00040   im3.setName("test_image_2");
00041   im3.showImage();
00042  
00043   // Zoom out the input image 2.5 times along both axes and 
00044   // store the result in a second image.
00045   Image< float > im4; 
00046   Zoom(im1, 2.5, im4);
00047   im4.setName("test_image_3");
00048   im4.showImage();
00049  
00050   // Zoom in the input image in place 2.5 times along both axes.
00051   Image< float > im5 = im1; 
00052   Zoom(im5, 1/2.5);
00053   im5.setName("test_image_4");
00054   im5.showImage();
00055  
00056   char l;
00057   cin >> l;
00058   im1.closeWindow();
00059   im2.closeWindow();
00060   im3.closeWindow();
00061   im4.closeWindow();
00062   im5.closeWindow();
00063   return(1);
00064 }