/* Copyright (c) 2001 C. Grigorescu S.E. Grigorescu */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tip.h> // Example program for the "Image" class. // // Usage: // test_image <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); } char l; // Read an image from the file specified by "argv[1]" and display it // Store the pixel values as floats. Image< float > im1; im1.readImage(argv[1]); im1.showImage(); // Create an empty image of size "128"x"128" with the name "Empty image" // and display it. Image< float > im2(128,128,"Empty image"); im2.showImage(); cin >> l; // Copy the image "im1" to "im2". im2 = im1; // Set the name of the image. im2.setName("Image_2.tif"); // Write the copy to the file specified by "setName". im2.writeImage(); // Print some statistics about the image "im2". cout << "Min: " << im2.min() << endl; cout << "Max: " << im2.max() << endl; cout << "Avg: " << im2.avg() << endl; cout << "Std.dev.:" << im2.dev() << endl; im2.showImage(); cin >> l; // Crop the image in such a way that only the rectangular area defined by // point (10,10) (as the upper left corner) and // point (100,100) (as the lower right corner) is left. im2.crop(10, 10, 100, 100); im2.showImage(); cin >> l; // Create a copy of "im1" in "im3" and set the pixel values // to twice their values; print some statistics and // display the new image Image< float > im3; im3 = im1; im3 *= 2; cout << "Min: " << im3.min() << endl; cout << "Max: " << im3.max() << endl; cout << "Avg: " << im3.avg() << endl; cout << "Std.dev.:" << im3.dev() << endl; im3.showImage(); cin >> l; // Close all display windows im1.closeWindow(); im2.closeWindow(); im3.closeWindow(); return(1); }