Created
May 9, 2018 13:08
-
-
Save jeasinema/1c16648ffb1cc3e00731fcc01ae681d6 to your computer and use it in GitHub Desktop.
An utils for draw split image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding:UTF-8 -*- | |
# File Name : split_draw.py | |
# Purpose : | |
# Creation Date : 09-05-2018 | |
# Last Modified : 2018年05月09日 星期三 21时06分55秒 | |
# Created By : Jeasine Ma [jeasinema[at]gmail[dot]com] | |
import numpy as np | |
import cv2 | |
def draw_split(imgs, col, row, border=20): | |
# Input: | |
# imgs: (N, H, W, 3) / [(H, W, 3)] | |
# Output: | |
# ret: (H', W', 3) | |
N = len(imgs) | |
H, W = imgs[0].shape[:2] | |
assert(col*row == N) | |
ret = np.zeros((H*col+border*(col+1), W*row+border*(row+1), 3), dtype=np.uint8) | |
for ind in range(N): | |
ret[(ind//row)*(H+border)+border:(ind//row)*(H+border)+border+H, | |
(ind%row)*(H+border)+border:(ind%row)*(H+border)+border+H, :] = imgs[ind] | |
return ret | |
if __name__ == '__main__': | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment