We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d77a295 commit 2b8a548Copy full SHA for 2b8a548
utils.py
@@ -0,0 +1,28 @@
1
+def combine_tocenter(src_image, dst_image):
2
+ ''' Combine two image to be one single image '''
3
+ # get shape
4
+ bh, bw, _ = dst_image.shape
5
+ sh, sw, _ = src_image.shape
6
+
7
+ # get center
8
+ lh = int((bh - sh) / 2 )
9
+ lw = int((bw - sw) / 2)
10
+ rh = bh - lh
11
+ rw = bw - lw
12
13
+ #normalize dimension error if dimension is not match
14
+ new_img = dst_image
15
+ nh, nw, _ = dst_image[lh:rh, lw:rw].shape
16
17
+ #find difference dimension between new shape and replacement image
18
+ kh = nh - sh
19
+ kw = nw - sw
20
21
+ #normalize dimension dimension
22
+ rh = rh - kh
23
+ rw = rw - kw
24
25
+ #Replace Image in center
26
+ new_img[lh:rh, lw:rw] = src_image
27
+ return new_img
28
0 commit comments