11 static float get_pixel(image m,
int x,
int y,
int c) {
12 assert(x < m.w && y < m.h && c < m.c);
13 return m.data[c * m.h * m.w + y * m.w + x];
19 image** alphabets = (image**)calloc(nsize,
sizeof(image));
20 char* labels =
"/labels/%d_%d.png";
21 char* files = (
char*)malloc(1 + strlen(datafile) + strlen(labels));
22 strcpy(files, datafile);
23 strcat(files, labels);
24 for (j = 0; j < nsize; ++j) {
25 alphabets[j] = (image*)calloc(128,
sizeof(image));
26 for (i = 32; i < 127; ++i) {
28 sprintf(buff, files, i, j);
29 alphabets[j][i] = load_image_color(buff, 0, 0);
38 if (p.c == 3) rgbgr_image(p);
42 for (y = 0; y < p.h; ++y) {
43 for (x = 0; x < p.w; ++x) {
44 for (k = 0; k < p.c; ++k) {
45 disp.data[y * step + x * p.c + k] = (
unsigned char)(
get_pixel(p, x, y, k) * 255);
image ** load_alphabet_with_file(char *datafile)
static float get_pixel(image m, int x, int y, int c)
void generate_image(image p, cv::Mat &disp)