소스 뷰어
import cv2, numpy as np, matplotlib.pyplot as plt

# 입력 픽셀 정의
w = 100; h = w
red_image = np.zeros((w, h, 3), dtype=np.uint8)
red_image[:, :, 2] = 255  # 빨간색 채널(BGR의 R 채널)을 255로 설정

blue_image = np.zeros((w, h, 3), dtype=np.uint8)
blue_image[:, :, 0] = 255  # 파란색 채널(BGR의 B 채널)을 255로 설정

p1 = red_image
p2 = blue_image 

# (alpha, beta, gamma) 리스트
blend_params = [
    (0.5, 0.5,  0), # α=0.5, β=0.5, γ=검정색
    (0.8, 0.2,  0), # α=0.8, β=0.2, γ=검정색
    (0.2, 0.8,  0), # α=0.2, β=0.8, γ=검정색
    (0.5, 0.5, 50), # α=0.5, β=0.5, γ=회색
]

# 합성 결과 저장 리스트
results = []

for alpha, beta, gamma in blend_params:
    # 가중합 계산
    img = cv2.addWeighted(p1, alpha, p2, beta, gamma)
    results.append(( p1, f"α={alpha}" ))
    results.append(( p2, f"β={beta}"  ))
    results.append((img, f"γ={gamma}" ))
pass

# 결과 출력
plt.figure(figsize=(6, 6)) 

for idx, (img, title) in enumerate( results ) :
    plt.subplot( len(results)//2, 6, idx + 1)
    plt.imshow( img[:,:,::-1] ) # 채널 변환
    plt.title( title )
    plt.axis('off') 
pass

plt.tight_layout()
plt.show()
No description has been provided for this image