ifw-odp  2.0.0-alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
clipm_image_sim.c File Reference
#include "clipm_image_sim.h"
#include "clipm_math.h"
#include "clipm_math_rng.h"
#include "clipm_priv_checks.h"
#include "clipm_priv_error.h"
#include "clipm_priv_image.h"
#include <math.h>

Macros

#define clipm_image_sim_noise_gaussian_BODY(TYPE)
 

Functions

cpl_error_code clipm_image_sim_noise_gaussian (cpl_image *img_modified, const cpl_size window_xxyy[4], double sigma)
 Add white gaussian noise to an image. More...
 
cpl_error_code clipm_image_sim_circle (cpl_image *img_modified, double centre_x, double centre_y, double radius, double brightness)
 Add a circle to an existing image (additively, on top). More...
 
cpl_error_code clipm_image_sim_rectangle (cpl_image *img_modified, double centre_x, double centre_y, double angle, double length, double width, double brightness)
 Add a circle to an existing image (additively, on top). More...
 

Macro Definition Documentation

#define clipm_image_sim_noise_gaussian_BODY (   TYPE)
Value:
do { \
cpl_size x, \
y; \
TYPE *tdata; \
\
tdata = (TYPE*)data; \
\
for (y = 0; y < wdwsize[1]; y++) \
{ \
for (x = 0; x < wdwsize[0]; x++) \
{ \
if (badp == NULL || badp[x] == CPL_BINARY_0) \
{ \
double g; \
g = sigma * clipm_math_rng_gaussian(); \
if (noise_abs_limit >= 0.0 && fabs(g) > noise_abs_limit) \
g = (g < 0.0 ? -1 : +1) * noise_abs_limit; \
if (type == CPL_TYPE_INT) \
tdata[x] += clipm_math_round_d2i(g); \
else \
tdata[x] += g; \
} \
} \
tdata += size[0]; \
if (badp != NULL) \
badp += size[0]; \
} \
} while (0)
double clipm_math_rng_gaussian(void)
Generate gaussian-distributed random number.
Definition: clipm_math_rng.c:255
int clipm_math_round_d2i(double in)
Round a double value to the nearest integer.
Definition: clipm_math.c:73