/* Copyright (c) 2001 C. Grigorescu */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <tip.h> // Example program for "DistanceTransform" function. // // Usage: // test_dist_trans <input_image> <distance_type> // where <distance_type> can be: // 0 - Euclidian distance using chamfer (5,7,11) // 1 - Euclidian distance using chamfer (3,4) // 2 - City-block distance // 3 - Chessboard distance // int main(int argc, char *argv[]) { // Test for the correct number of arguments in the command line if (argc != 3) { cout << endl << "Usage: " << argv[0] << " <input_image> <distance_type>" << endl << endl; cout << " where <distance_type> can be: " << endl; cout << " 0 - Euclidian distance using chamfer (5,7,11)" << endl; cout << " 1 - Euclidian distance using chamfer (3,4) " << endl; cout << " 2 - City-block distance " << endl; cout << " 3 - Chessboard distance " << endl; exit(0); } // Read an image from the file specified by "argv[1]" and display it ByteImage im1; im1.readImage(argv[1]); im1.showImage(); // Set the distance type int dist_type = atoi(argv[2]); IntImage im2; // Perform the distance transform and // display the output image switch(dist_type) { case 0: DistanceTransform(im1, EUCLID, im2); break; case 1: DistanceTransform(im1, EUCLID_1, im2); break; case 2: DistanceTransform(im1, CITY_BLOCK, im2); break; case 3: DistanceTransform(im1, CHESSBOARD, im2); break; default:; } im2.showImage(); char l; cin >> l; im1.closeWindow(); im2.closeWindow(); return(1); }