| 56 | |
| 57 | |
| 58 | def padding_image(image): |
| 59 | height_o, width_o = image.shape[0:2] |
| 60 | if height_o == image_max_height and width_o == image_max_width: |
| 61 | return image |
| 62 | h_pad_len_top = int((image_max_height - height_o) / 2) |
| 63 | h_pad_len_bottom = image_max_height - height_o - h_pad_len_top |
| 64 | w_pad_len_left = int((image_max_width - width_o) / 2) |
| 65 | h_pad_len_right = image_max_width - width_o - w_pad_len_left |
| 66 | |
| 67 | return np.pad(image, ((h_pad_len_top, h_pad_len_bottom), (w_pad_len_left, h_pad_len_right), (0, 0)), 'constant', |
| 68 | constant_values=0) |