MCPcopy Create free account
hub / github.com/Mercury7353/PyBench / test_task_93

Function test_task_93

data/unit_test/tests.py:1008–1027  ·  view source on GitHub ↗
(trajectory)

Source from the content-addressed store, hash-verified

1006 assert avg_brightness_image < avg_brightness_ref_image, "The brightness of the image is not lower than the reference image."
1007
1008def test_task_93(trajectory):
1009 image_path = "./output/93.png"
1010 ref_path = "./data/93.jpeg"
1011 # 打开目标图像和参考图像
1012 image = Image.open(image_path)
1013 ref_image = Image.open(ref_path)
1014
1015 # 将图像转换为灰度图
1016 gray_image = image.convert('L')
1017 gray_ref_image = ref_image.convert('L')
1018
1019 # 将灰度图转换为numpy数组
1020 gray_array = np.array(gray_image)
1021 gray_ref_array = np.array(gray_ref_image)
1022
1023 # 计算每个图像的平均亮度
1024 avg_brightness_image = np.mean(gray_array)
1025 avg_brightness_ref_image = np.mean(gray_ref_array)
1026
1027 assert avg_brightness_image > avg_brightness_ref_image, "The brightness of the image is not lower than the reference image."
1028
1029
1030def test_task_94(trajectory):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected