Skip to content

Instantly share code, notes, and snippets.

@cemysf
Created March 6, 2019 10:25
Show Gist options
  • Select an option

  • Save cemysf/dedb1455f8d407eb5e2236c46930cd6c to your computer and use it in GitHub Desktop.

Select an option

Save cemysf/dedb1455f8d407eb5e2236c46930cd6c to your computer and use it in GitHub Desktop.
stacking images
"""
assuming we have 4 images and we need to show them on one window
img1 | img2
------|-------
img3 | img4
note: images should have the same shape
"""
resize_mult = 0.5
# first row
r11 = cv2.resize(img1, (0, 0), None, resize_mult, resize_mult)
r12 = cv2.resize(img2, (0, 0), None, resize_mult, resize_mult)
row1 = np.hstack((r11, r12))
# second row
r21 = cv2.resize(img3, (0, 0), None, resize_mult, resize_mult)
r22 = cv2.resize(img4, (0, 0), None, resize_mult, resize_mult)
row2 = np.hstack((r21, r22))
# whole image
img = np.vstack((row1,row2))
cv2.imshow("img",img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment