|
Bsoft
1.9
Bernard's software package
|
Header file for functions for creating random images. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <math.h>#include <time.h>#include "rwimg.h"Go to the source code of this file.
Functions | |
| Bimage * | img_random_uniform (int nimg, Vector3< int > size, double min, double max) |
| Generates an image with a uniform random distribution of densities. More... | |
| Bimage * | img_random_gaussian (int nimg, Vector3< int > size, double avg, double std) |
| Generates an image with a gaussian random distribution of densities. More... | |
| Bimage * | img_random_poisson (int nimg, Vector3< int > size, double avg) |
| Generates an image with a poisson random distribution of densities. More... | |
| Bimage * | img_random_logistical (int nimg, Vector3< int > size, double avg, double std) |
| Generates an image with a gaussian random distribution of densities. More... | |
| Bimage * | img_spectral_noise (int nimg, Vector3< int > size, double alpha) |
| Generates a noise map with a defined spectral decay. More... | |
| int | img_add_gaussian_noise (Bimage *p, double snr) |
| Adds gaussian random noise to an image. More... | |
| int | img_add_poisson_noise (Bimage *p) |
| Adds poisson random noise to an image. More... | |
Header file for functions for creating random images.
Definition in file img_random.h.
| int img_add_gaussian_noise | ( | Bimage * | p, |
| double | snr | ||
| ) |
Adds gaussian random noise to an image.
| *p | image to add noise to (modified, converted to floating point). |
| snr | signal_to_noise ratio. |
An image is generated composed of gaussian noise with an average of
zero and a standard deviation of:
std_noise = std_image/sqrt(snr)
The noise image is added to the input image.
Statistics are calculated before returning.
Reference: Press W.H. et al (1992) Numerical Recipes in C. Definition at line 284 of file img_random.cpp.
| int img_add_poisson_noise | ( | Bimage * | p | ) |
Adds poisson random noise to an image.
| *p | image to add noise to (modified, converted to floating point). |
Each value in the image is taken as the average for generating a new value with a Poisson distribution. Values less than zero become zero. Values above zero become integer values varying from the original values according to a Poisson distribution. Statistics are calculated before returning.Reference: Press W.H. et al (1992) Numerical Recipes in C.
Definition at line 324 of file img_random.cpp.
Generates an image with a gaussian random distribution of densities.
| nimg | number of sub-images to generate. |
| size | 3-valued vector for the size of the image. |
| avg | average. |
| std | standard deviation. |
An image with a given datatype, number of subimages, and size is
generated with densities with a gaussian distribution with a given
average and standard deviation:
density = average + std_dev*sqrt(-2*log(random_value))*
cos(2*PI*random_value);
where random_value is between 0 and 1.
The output image is floating point.
Statistics are calculated before returning. Definition at line 80 of file img_random.cpp.
Generates an image with a gaussian random distribution of densities.
| nimg | number of sub-images to generate. |
| size | 3-valued vector for the size of the image. |
| avg | average. |
| std | standard deviation. |
An image with a given datatype, number of subimages, and size is
generated with densities with a logistical differential distribution
with a given average and standard deviation:
density = average + (std_dev/golden)*ln(1/random_value - 1)
where random_value is between 0 and 1 and:
golden = (sqrt(5) + 1)/2
The output image is floating point.
Statistics are calculated before returning.
Reference: Press W.H. et al (1992) Numerical Recipes in C. Definition at line 175 of file img_random.cpp.
Generates an image with a poisson random distribution of densities.
| nimg | number of sub-images to generate. |
| size | 3-valued vector for the size of the image. |
| avg | average. |
Algorithm taken from Numerical Recipes in C.
The poisson distribution is given for j = 0,1,... by:
avg^j * exp(-avg)
P(j) = -----------------
j!
Note that only positive integer values are defined for j and sum(P(j)) = 1.
An array of floating point numbers is generated with a poisson
distribution with a given average. The standard deviation is:
std = sqrt(avg)
If the average <= 0, the function exits.
Statistics are calculated before returning.
Reference: Press W.H. et al (1992) Numerical Recipes in C. Definition at line 127 of file img_random.cpp.
Generates an image with a uniform random distribution of densities.
| nimg | number of sub-images to generate. |
| size | 3-valued vector for the size of the image. |
| min | minimum density value. |
| max | maximum density value. |
An image with a given datatype, number of subimages, and size is
generated with densities distributed uniformly in the range of the
given minimum and maximum:
density = random_value*(max - min) + min
where random_value is between 0 and 1.
The average and standard deviation are:
average = (max + min)/2
standard deviation = 0.5*sqrt(1/3)*(max - min).
The output image is floating point.
Statistics are calculated before returning. Definition at line 38 of file img_random.cpp.
Generates a noise map with a defined spectral decay.
| nimg | number of sub-images. |
| size | image size. |
| alpha | spectral decay. |
Uniform random phases are generated and the amplitudes are set to:
amp = s^(-alpha/2). Definition at line 210 of file img_random.cpp.