0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

二つの画像を融合する

Posted at

前提条件

RGB同士またはグレースケール同士の画像を利用すること。どちらかが異なるカラースケールの場合、融合ができないです。

処理内容

読み込みされた二つの画像を一つの画像として融合され、表示されます。画像のサイズ調整がされるため、元々の2個の画像のサイズは異なっても問題ないです。

imgmerge.py
import cv2

# read image 1
img1 = cv2.imread("cat1.jpg")
# read image 2
img2 = cv2.imread("cat2.jpg")

# set the size of two images to the same size. can't merge image of different size.
img1 = cv2.resize(img1,(306,148))
img2 = cv2.resize(img2,(306,148))

# set weight of image 1
alpha = 0.3
# set weight of image 2
beta = 0.7

# merge image
final_image = cv2.addWeighted(img1, alpha, img2, beta, 0.0)

# show result
cv2.imshow('Img',final_image)
# leave window open until it is closed
cv2.waitKey(0)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?