Commit 903d944c authored by Thomas White's avatar Thomas White
Browse files

Add --no-noise option

parent d30508aa
......@@ -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;
......
......@@ -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 */
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment