评价指标测试
This commit is contained in:
		
							
								
								
									
										26
									
								
								image_fusion/evaluate_module/evaluation_test.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								image_fusion/evaluate_module/evaluation_test.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  | 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) | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user