/* * ===================================================================================== * * Filename: basicexa.cxx * * Description: The basic example of how to use the artimagen library in * C++. This program generates an artificial image of a * Gold-on-Carbon sample and saves it to an 8-bit uncompressed * TIFF file. * * Compilation: g++ -O3 -lartimagen -o basicexa basicexa.cxx * or for static build: * g++ basicexa.cxx $ARTIMAGEN_BASE/src/.libs/libartimagen.a \ * -lfftw3 -ltiff -I \ * $ARTIMAGEN_BASE/src/libartimagen -o basicexa * * * Version: 1.0 * Created: 10/14/2009 12:32:49 PM * Revision: none * Compiler: g++ * * Author: Dr. Petr Cizmar (pc), petr.cizmar@nist.gov * Company: National Institute od Standards and Technology * * ===================================================================================== */ #define SIZEX 1124 #define SIZEY 868 #include #include #include #include using namespace artimagen; int main(){ srandom(time(0)); CApp app; // initialization of the generator t_gc_definition gc_def; gc_def.sizex = SIZEX; gc_def.sizey = SIZEY; gc_def.ee_coefficient = 0.2; gc_def.ee_top_above_base = 0.3; gc_def.base_level = 0.5; gc_def.base_level_variation = 0.1; gc_def.grain_min_size = 5; gc_def.grain_max_size = 15; gc_def.number_of_grains = SIZEX*SIZEY/2000; gc_def.rotation = 0; gc_def.fs_density = 7e-3; gc_def.fs_min_r = 6; gc_def.fs_max_r = 10; gc_def.fs_min_coe = 0.95; gc_def.fs_max_coe = 1.05; CGoldOnCarbonSample sam(&gc_def); CImage im(SIZEX,SIZEY); CWavyBackgroud back(0.2,0.3,5,5); // pars: min-bg-level, max-bg-level, x-density, y-density back.apply(&im); // paint the background pattern sam.paint(&im); // paint the sample CGaussianPsf psf(SIZEX,SIZEY,0.7,2,30); // pars: sizex, sizey, sigma, astig. ratio, astig. angle. psf.apply(&im); // apply the blur t_vib_definition vibdef; vibdef.pixel_dwell_time = 100; vibdef.min_frequency = 1; vibdef.max_frequency = 100; vibdef.max_amplitude = 0.2; vibdef.number_of_frequencies = 10; vibdef.pixel_dead_time = 25; vibdef.line_dead_time = 200; CVibration vib(&vibdef); vib.apply(&im, 0); // apply the drift-distorsion im.crop(50,50,SIZEX-50,SIZEY-50); // pars: left-crop-margin, top-crop margin, right.., bottom. CGaussianNoise gn(0.07); // pars: sigma gn.apply(&im); // apply the gaussian noise im.tiff_write("test.tiff","Generated by ArtImaGen software by Petr Cizmar @ NIST", BI_8B); // pars: file name, file comment, BI_8B for 8-bit image, BI_16B // for 16-bit-image output. }