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

test_conversion.cpp

00001 /* Copyright (c) 2001 C. Grigorescu S.E. Grigorescu */
00002 
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <tip.h>
00007 
00008 //   Example program for the conversion facilities.
00009 //
00010 //   Usage:
00011 //      test_conversion <input_image>
00012 //
00013 
00014 int main(int argc, char *argv[])
00015 {
00016   // Test for the correct number of arguments in the command line.
00017   if (argc != 2) {
00018     cout << "Usage: " << argv[0] << " <input_image>" << endl;
00019     exit(0);
00020   }
00021 
00022   char l;
00023 
00024   // Read an image from the file specified by "argv[1]" and display it.
00025   Image< float > im1;
00026   im1.readImage(argv[1]);
00027   im1.showImage();
00028 
00029   IntImage im2(128,128,"Empty image");
00030   im2.showImage();
00031   cin >> l;
00032 
00033   // Conversion between Image< float > and IntImage.
00034   float2int(im1, im2);
00035   im2.showImage();
00036 
00037   // Conversion between Image< float > and Image< byte >.
00038   Image< byte > im3;
00039   float2byte(im1, im3);
00040   im3.showImage();
00041 
00042   // Conversion between Image< byte > and ByteImage.
00043   ByteImage im4;
00044   im4 = im3;
00045   im4.showImage();
00046   im3 = im4;
00047 
00048   cin >> l;
00049   // Close all displaying windows
00050   im1.closeWindow();
00051   im2.closeWindow();
00052   im3.closeWindow();
00053   im4.closeWindow();
00054   return(1);
00055 }