본문 바로가기
Python/Opencv

Python Opencv 이미지 붙이기(cv2.vconcat cv2.hconcat)

by Cum 2022. 10. 27.
728x90
반응형

가끔 이미지를 붙여서 사용할 때가 있다.

그럴 때마다 opencv에 있는 vconcat과 hconcat을 사용하는데

방향이 항상 헷갈려서 기록한다.

 

import cv2

img1 = cv2.imread("11.png")
img2 = cv2.imread("22.png")

img1 = cv2.resize(img1, (int(img1.shape[0] / 2), int(img1.shape[1] / 2)))
img2 = cv2.resize(img2, (int(img2.shape[0] / 2), int(img2.shape[1] / 2)))

img3 = cv2.vconcat([img1, img2])
cv2.imshow("t1", img3)
cv2.waitKey(0)

img4 = cv2.hconcat([img1, img2])
cv2.imshow("t2", img4)
cv2.waitKey(0)

cv2.vconcat 은 위아래로 붙여준다.

cv2.hconcat은 양옆으로 붙여준다.

 

 

참고

https://docs.opencv.org/3.4.3/d6/d00/tutorial_py_root.html

728x90
반응형

'Python > Opencv' 카테고리의 다른 글

Python OpenCv 이미지 투명하게 만들기(cv2.addWeighted)  (1) 2022.09.23

댓글