diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/detector.c | 10 | ||||
-rw-r--r-- | src/detector.h | 2 | ||||
-rw-r--r-- | src/pattern_sim.c | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/detector.c b/src/detector.c index 222e539c..de1efc2b 100644 --- a/src/detector.c +++ b/src/detector.c @@ -142,7 +142,7 @@ static uint16_t *bloom(int *hdr_in, int width, int height) } -void record_image(struct image *image, int do_water) +void record_image(struct image *image, int do_water, int do_poisson) { int x, y; double total_energy, energy_density; @@ -171,6 +171,7 @@ void record_image(struct image *image, int do_water) for ( y=0; y<image->height; y++ ) { int counts; + double cf; double intensity, sa, water; double complex val; double dsq, proj_area; @@ -198,7 +199,12 @@ void record_image(struct image *image, int do_water) /* Projected area of pixel divided by distance squared */ sa = proj_area / (dsq + Lsq); - counts = poisson_noise(intensity * ph_per_e * sa * DQE); + if ( do_poisson ) { + counts = poisson_noise(intensity * ph_per_e * sa * DQE); + } else { + cf = intensity * ph_per_e * sa * DQE; + counts = (int)cf; + } image->hdr[x + image->width*y] = counts; diff --git a/src/detector.h b/src/detector.h index 4d540d07..f4c6f562 100644 --- a/src/detector.h +++ b/src/detector.h @@ -18,6 +18,6 @@ #include "image.h" -extern void record_image(struct image *image, int do_water); +extern void record_image(struct image *image, int do_water, int do_poisson); #endif /* DETECTOR_H */ diff --git a/src/pattern_sim.c b/src/pattern_sim.c index 881ef663..0c5350a8 100644 --- a/src/pattern_sim.c +++ b/src/pattern_sim.c @@ -44,6 +44,7 @@ static void show_help(const char *s) " -r, --random-orientation Use a randomly generated orientation\n" " (a new orientation will be used for each image).\n" " --no-water Do not simulate water background.\n" +" --no-noise Do not calculate Poisson noise.\n" ); } @@ -142,6 +143,7 @@ int main(int argc, char *argv[]) int config_randomquat = 0; int config_noimages = 0; int config_nowater = 0; + int config_nonoise = 0; int number = 1; /* Index for the current image */ int n_images = 1; /* Generate one image by default */ int done = 0; @@ -155,6 +157,7 @@ int main(int argc, char *argv[]) {"number", 1, NULL, 'n'}, {"no-images", 0, &config_noimages, 1}, {"no-water", 0, &config_nowater, 1}, + {"no-noise", 0, &config_nonoise, 1}, {0, 0, NULL, 0} }; @@ -230,7 +233,7 @@ int main(int argc, char *argv[]) image.hdr = NULL; get_diffraction(&image); - record_image(&image, !config_nowater); + record_image(&image, !config_nowater, !config_nonoise); if ( config_nearbragg ) { output_intensities(&image); |