/* Copyright (c) 2001 S.E. Grigorescu */ #include <iostream.h> #include <stdio.h> #include <stdlib.h> #include <tip.h> // Example program for the "Noise" function. // // Usage: // test_noise <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 > img, im1; im1.readImage(argv[1]); im1.setName("test_image"); im1.showImage(); char l; // Add noise having a uniform distribution in the interval [0, 1] to the image. // Initialize the random number generator with 16. img = im1; Noise(img, "uniform", 16); img.showImage(); cin >> l; // Add Gaussian noise with mean 0 and standard deviation 1 to the image. img = im1; Noise(img); img.showImage(); cin >> l; // Add salt and pepper noise to the image. // Initialize the random number generator with 8. img = im1; Noise(img, "salt&pepper", 8); img.showImage(); cin >> l; // Add noise having a uniform distribution in the interval [-60, 10] to the image. img = im1; Noise(img, "uniform", -60, 10); img.showImage(); cin >> l; // Add Gaussian noise with mean 10 and standard deviation 30 to the image. // Initialize the random number generator with 9. img = im1; Noise(img, 10, 30, 9); img.showImage(); cin >> l; // Add salt and pepper noise to the image, in such a way that 15% of the image pixels are affected. // Initialize the random number generator with 71. img = im1; Noise(img, "salt&pepper", 15, 0, 71); img.showImage(); cin >> l; return(1); }