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

Function test_task_95

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

Source from the content-addressed store, hash-verified

1051 assert contrast_image < contrast_ref_image, "The contrast of the image is not lower than the reference image."
1052
1053def test_task_95(trajectory):
1054 image_path = "./output/95.png"
1055 ref_path = "./data/95.jpeg"
1056
1057 # 打开目标图像和参考图像
1058 image = Image.open(image_path)
1059 ref_image = Image.open(ref_path)
1060
1061 # 将图像转换为灰度图
1062 gray_image = image.convert('L')
1063 gray_ref_image = ref_image.convert('L')
1064
1065 # 将灰度图转换为numpy数组
1066 gray_array = np.array(gray_image)
1067 gray_ref_array = np.array(gray_ref_image)
1068
1069 # 计算每个图像的对比度(标准差)
1070 contrast_image = np.std(gray_array)
1071 contrast_ref_image = np.std(gray_ref_array)
1072
1073
1074 assert contrast_image > contrast_ref_image, "The contrast of the image is not lower than the reference image."
1075
1076def test_task_96(trajectory):
1077 image_path = "./output/96.png"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected