24 #include "allheaders.h"
67 Pix* pix = pixConvertTo8(input,
false);
70 int width = pixGetWidth(input);
71 int height = pixGetHeight(input);
77 input = pixErodeGray(pix, 3, 3);
82 pix = pixBlockconv(input, 1, 1);
85 if (rotation !=
NULL) {
86 float radians_clockwise = 0.0f;
88 radians_clockwise = *rotation;
89 }
else if (randomizer !=
NULL) {
90 radians_clockwise = randomizer->
SignedRand(kRotationRange);
93 input = pixRotate(pix, radians_clockwise,
94 L_ROTATE_AREA_MAP, L_BRING_IN_WHITE,
97 *rotation = radians_clockwise;
103 if (exposure >= 3 || exposure == 1) {
109 input = pixErodeGray(pix, 3, 3);
115 int erosion_offset = 0;
127 l_uint32* data = pixGetData(input);
128 for (
int y = 0; y < height; ++y) {
129 for (
int x = 0; x < width; ++x) {
130 int pixel = GET_DATA_BYTE(data, x);
131 if (randomizer !=
NULL)
132 pixel += randomizer->
IntRand() % (kSaltnPepper*2 + 1) - kSaltnPepper;
133 if (height + width > kMinRampSize)
134 pixel -= (2*x + y) * 32 / (height + width);
135 pixel += erosion_offset;
140 SET_DATA_BYTE(data, x, pixel);
const int kExposureFactor
const float kRotationRange
double SignedRand(double range)
Pix * DegradeImage(Pix *input, int exposure, TRand *randomizer, float *rotation)