40 if ( size.
volume() < 1 )
return NULL;
42 size_t datasize = (size_t) (nimg*size.
volume());
51 cout <<
"Generating a random image with a uniform distribution:" << endl;
52 cout <<
"Minimum and maximum: " <<
57 cout <<
"Generating a random image with a uniform distribution" << endl << endl;
82 if ( size.
volume() < 1 )
return NULL;
84 size_t datasize = (size_t) (nimg*size.
volume());
94 cout <<
"Generating a random image with a gaussian distribution:" << endl;
95 cout <<
"Avg and std: " <<
100 cout <<
"Generating a random image with a gaussian distribution" << endl << endl;
130 error_show(
"Error in img_random_poisson: The average for a Poisson distribution must be > 0!", __FILE__, __LINE__);
134 if ( size.
volume() < 1 )
return NULL;
136 size_t datasize = (size_t) (nimg*size.
volume());
145 cout <<
"Generating a random image with a poisson distribution:" << endl;
146 cout <<
"Avg and std: " <<
151 cout <<
"Generating a random image with a poisson distribution" << endl << endl;
177 if ( size.
volume() < 1 )
return NULL;
179 size_t datasize = (size_t) (nimg*size.
volume());
188 cout <<
"Generating a random image with a logistical differential distribution:" << endl;
189 cout <<
"Avg and std: " <<
194 cout <<
"Generating a random image with a logistical differential distribution" << endl << endl;
212 if ( size.
volume() < 1 )
return NULL;
217 unsigned long i, j, n, x, y, z, imgsize = (
unsigned long) size.
volume();
219 double x2, y2, z2, s2, w, sum;
220 double fac(-alpha/4);
223 cout <<
"Generating a noise image:" << endl;
225 cout <<
"Alpha: " << alpha << endl << endl;
227 cout <<
"Generating a noise image" << endl;
231 cout <<
"DEBUG img_noise: random array size " << datasize << endl;
233 for ( i=1; i<datasize; i++ ) p->
set(i, phi[i]);
236 for ( i=n=0; n<p->
images(); n++ ) {
238 for ( z=0; z<p->
sizeZ(); z++ ) {
239 z2 = z*1.0L/p->
sizeZ();
240 if ( z2 >= 0.5 ) z2 -= 1;
242 for ( y=0; y<p->
sizeY(); y++ ) {
243 y2 = y*1.0L/p->
sizeY();
244 if ( y2 >= 0.5 ) y2 -= 1;
246 for ( x=0; x<p->
sizeX(); x++, i++ ) {
247 x2 = x*1.0L/p->
sizeX();
248 if ( x2 >= 0.5 ) x2 -= 1;
259 sum = sqrt(sum/(3*imgsize));
260 for ( j=n*imgsize; j<(n+1)*imgsize; j++ ) p->
set(j, p->
complex(j)/sum);
286 if ( snr <= 0 || snr > 1000 )
return 0;
289 cout <<
"Adding Gaussian noise to an image with SNR = " << snr << endl << endl;
327 cout <<
"Adding Poisson noise to an image" << endl << endl;
331 unsigned long i, nzero = 0, datasize = p->
data_size();
333 for ( i=0; i<datasize; i++ ) {
334 if ( (*p)[i] <= 0 ) nzero++;
339 cout <<
"Number of zero voxels: " << nzero <<
" (" << nzero*100.0/datasize <<
" %)" << endl;
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for general utilities.
int img_add_poisson_noise(Bimage *p)
Adds poisson random noise to an image.
Bimage * img_spectral_noise(int nimg, Vector3< int > size, double alpha)
Generates a noise map with a defined spectral decay.
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
double average(size_t cc, double xf, double yf, double zf, size_t nn, double iscale)
Averages in the xy plane when scaling is less than 1.
size_t statistics()
Calculates the statistics for an image.
General image parameter class.
Complex< double > complex(size_t j)
Returns a complex value at the given index.
float * random_array_poisson(int n, double avg)
Generates a series with a poisson random distribution of values.
float * random_array_logistical(long n, double avg, double std)
Generates an array with a logistical random distribution.
General FFT for n-dimensional data.
Header file for combining two images in various ways.
void add(size_t j, double v)
Bimage * img_random_uniform(int nimg, Vector3< int > size, double min, double max)
Generates an image with a uniform random distribution of densities.
void set(size_t j, double v)
Sets a single value at the given index.
double standard_deviation()
Bimage * img_random_poisson(int nimg, Vector3< int > size, double avg)
Generates an image with a poisson random distribution of densities.
Bimage * img_random_gaussian(int nimg, Vector3< int > size, double avg, double std)
Generates an image with a gaussian random distribution of densities.
int img_add_gaussian_noise(Bimage *p, double snr)
Adds gaussian random noise to an image.
Header file for 2D and 3D image I/O.
float * random_array_uniform(long n, double min, double max)
Generates a series with a uniform random distribution.
double random_poisson(double avg)
Generates a value deviating from the average based on a poisson distribution.
Bimage * img_random_logistical(int nimg, Vector3< int > size, double avg, double std)
Generates an image with a gaussian random distribution of densities.
float * random_array_gaussian(long n, double avg, double std)
Generates a series with a gaussian random distribution of values.