@@ -95,6 +95,7 @@ Pix* DegradeImage(Pix* input, int exposure, TRand* randomizer,
95
95
input = pix;
96
96
int width = pixGetWidth (input);
97
97
int height = pixGetHeight (input);
98
+
98
99
if (exposure >= 2 ) {
99
100
// An erosion simulates the spreading darkening of a dark copy.
100
101
// This is backwards to binary morphology,
@@ -167,6 +168,12 @@ Pix* DegradeImage(Pix* input, int exposure, TRand* randomizer,
167
168
}
168
169
data += input->wpl ;
169
170
}
171
+
172
+ pix = input;
173
+ input = PrepareDistortedPix (pix, false , true , true , true , true ,
174
+ 1 , randomizer, nullptr );
175
+ pixDestroy (&pix);
176
+
170
177
return input;
171
178
}
172
179
@@ -181,8 +188,6 @@ Pix* PrepareDistortedPix(const Pix* pix, bool perspective, bool invert,
181
188
GenericVector<TBOX>* boxes) {
182
189
Pix* distorted = pixCopy (nullptr , const_cast <Pix*>(pix));
183
190
// Things to do to synthetic training data.
184
- if (invert && randomizer->SignedRand (1.0 ) < 0 )
185
- pixInvert (distorted, distorted);
186
191
if ((white_noise || smooth_noise) && randomizer->SignedRand (1.0 ) > 0.0 ) {
187
192
// TODO(rays) Cook noise in a more thread-safe manner than rand().
188
193
// Attempt to make the sequences reproducible.
@@ -210,6 +215,8 @@ Pix* PrepareDistortedPix(const Pix* pix, bool perspective, bool invert,
210
215
(*boxes)[b].set_right ((*boxes)[b].left () + 1 );
211
216
}
212
217
}
218
+ if (invert && randomizer->SignedRand (1.0 ) < -0.5 )
219
+ pixInvert (distorted, distorted);
213
220
return distorted;
214
221
}
215
222
0 commit comments