20 #include "allheaders.h"
59 cached_x_scale_ = factor;
75 tprintf(
"Input::Backward should not be called!!\n");
84 const Network* network,
int min_width,
85 TRand* randomizer,
float* image_scale) {
90 &width, &height,
nullptr);
92 tprintf(
"Bad pix from ImageData!\n");
95 if (width < min_width || height < min_width) {
96 tprintf(
"Image too small to scale!! (%dx%d vs min width of %d)\n", width,
113 bool color = shape.
depth() == 3;
114 Pix* var_pix = const_cast<Pix*>(pix);
115 int depth = pixGetDepth(var_pix);
116 Pix* normed_pix =
nullptr;
122 normed_pix = pixClone(var_pix);
124 normed_pix = pixConvertTo32(var_pix);
128 normed_pix = pixClone(var_pix);
130 normed_pix = pixConvertTo8(var_pix,
false);
132 int height = pixGetHeight(normed_pix);
133 int target_height = shape.
height();
134 if (target_height == 1) target_height = shape.
depth();
135 if (target_height != 0 && target_height != height) {
137 float im_factor = static_cast<float>(target_height) / height;
138 Pix* scaled_pix = pixScale(normed_pix, im_factor, im_factor);
139 pixDestroy(&normed_pix);
140 normed_pix = scaled_pix;
142 input->
FromPix(shape, normed_pix, randomizer);
143 pixDestroy(&normed_pix);