| 501 | } |
| 502 | |
| 503 | image copyMaker(image im, int top, int bottom, int left, int right, float value) |
| 504 | { |
| 505 | int width = im.w + left + right; |
| 506 | int height = im.h + top + bottom; |
| 507 | image resImg = make_image(width, height, im.c); |
| 508 | memset(resImg.data, value, sizeof(float) * width * height * im.c); |
| 509 | for(int c = 0; c < im.c; c++) |
| 510 | { |
| 511 | for(int i = top; i < height - bottom; i++) |
| 512 | { |
| 513 | for(int j = left; j < width - right; j++) |
| 514 | { |
| 515 | int resIndex = c * height * width + i * width + j; |
| 516 | int originIndex = c * im.w * im.h + (i - top) * im.w + (j - left); |
| 517 | resImg.data[resIndex] = im.data[originIndex]; |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | return resImg; |
| 523 | } |
| 524 | |
| 525 | void save_image(image im, const char* name) |
| 526 | { |