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

test_zoom.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 "Zoom" function.
//
//   Usage:
//      test_zoom <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< float > im1; 
  im1.readImage(argv[1]);
  im1.setName("test_image");
  im1.showImage();
 
  // Zoom out the input image 2.5 times along the x-axis and 1.3 times along the y-axis and 
  // store the result in a second image.
  Image< float > im2; 
  Zoom(im1, 2.5, 1.3, im2);
  im2.setName("test_image_1");
  im2.showImage();
 
  // Zoom in the input image 2.5 times along the x-axis and 1.3 times along the y-axis and 
  // store the result in a second image.
  Image< float > im3; 
  Zoom(im1, 1/2.5, 1/1.3, im3);
  im3.setName("test_image_2");
  im3.showImage();
 
  // Zoom out the input image 2.5 times along both axes and 
  // store the result in a second image.
  Image< float > im4; 
  Zoom(im1, 2.5, im4);
  im4.setName("test_image_3");
  im4.showImage();
 
  // Zoom in the input image in place 2.5 times along both axes.
  Image< float > im5 = im1; 
  Zoom(im5, 1/2.5);
  im5.setName("test_image_4");
  im5.showImage();
 
  char l;
  cin >> l;
  im1.closeWindow();
  im2.closeWindow();
  im3.closeWindow();
  im4.closeWindow();
  im5.closeWindow();
  return(1);
}