6#include "GrayLevelImage2D.hpp"
12 return (
double)random() / (double)RAND_MAX;
15int main(
int argc,
char** argv )
17 typedef GrayLevelImage2D::GrayLevel GrayLevel;
21 std::cerr <<
"Usage: bruit-impulsionnel <input.pgm> <output.pgm> <prob>" << std::endl;
25 ifstream input( argv[1] );
26 bool ok = img.importPGM( input );
29 std::cerr <<
"Error reading input file." << std::endl;
34 double prob = (argc > 3) ? atof( argv[ 3 ] ) : 0.01;
35 for ( Iterator it = img.
begin(), itE = img.end(); it != itE; ++it )
37 if ( rand01() < prob )
39 *it = ( rand01() < 0.5 ) ? 0 : 255;
42 ofstream output( argv[2] );
43 ok = img.exportPGM( output,
false );
46 std::cerr <<
"Error writing output file." << std::endl;
Iterator begin()
[gli2d-sec3]