Graduation-Project/image_fusion/evaluate_module/evaluation_test.py

27 lines
1000 B
Python
Raw Normal View History

2025-04-21 09:51:38 +00:00
from evaluate import *
# 创建模拟图像数据用于测试
# img1_gray原始灰度图像可见光
# img2_gray变换后的灰度图像红外模拟
# fusion_img融合图像可见光 + 红外)
# ref_img_for_ssim参考图像可见光RGB
# 创建基础灰度图像(梯度)
img1_gray = np.tile(np.linspace(50, 200, 256).astype(np.uint8), (256, 1))
# 模拟配准后的图像:加一点噪声和平移
img2_gray = np.roll(img1_gray, shift=5, axis=1) # 平移模拟配准偏差
noise = np.random.normal(0, 5, img2_gray.shape).astype(np.uint8)
img2_gray = cv2.add(img2_gray, noise)
# 创建 RGB 可见光图(重复三个通道)
ref_img_for_ssim = cv2.merge([img1_gray] * 3)
# 创建融合图像取两个灰度图平均后合并入RGB
fusion_Y = cv2.addWeighted(img1_gray, 0.5, img2_gray, 0.5, 0)
fusion_img = cv2.merge([fusion_Y, img1_gray, img2_gray])
# 运行评价函数
scores = evaluate_all(img1_gray, img2_gray, fusion_img, ref_img_for_ssim)