update GIMP examples and eval
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import os
|
||||
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
|
||||
def get_gimp_export_path():
|
||||
# Path to GIMP's configuration file. This example assumes GIMP version 2.10.
|
||||
@@ -21,21 +21,19 @@ def get_gimp_export_path():
|
||||
print("GIMP configuration file not found")
|
||||
return False
|
||||
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
def increase_saturation(image1_path: str, image2_path: str) -> float:
|
||||
def calculate_saturation(image):
|
||||
# convert the image to HSV mode
|
||||
hsv_image = image.convert("HSV")
|
||||
|
||||
def calculate_saturation(image):
|
||||
# convert the image to HSV mode
|
||||
hsv_image = image.convert("HSV")
|
||||
saturation_channel = hsv_image.split()[1]
|
||||
|
||||
saturation_channel = hsv_image.split()[1]
|
||||
# calculate the mean saturation level
|
||||
stat = ImageStat.Stat(saturation_channel)
|
||||
mean_saturation = stat.mean[0]
|
||||
|
||||
# calculate the mean saturation level
|
||||
stat = ImageStat.Stat(saturation_channel)
|
||||
mean_saturation = stat.mean[0]
|
||||
return mean_saturation
|
||||
|
||||
return mean_saturation
|
||||
|
||||
def increase_saturation(image1_path, image2_path):
|
||||
image1 = Image.open(image1_path)
|
||||
image2 = Image.open(image2_path)
|
||||
|
||||
@@ -45,17 +43,17 @@ def increase_saturation(image1_path, image2_path):
|
||||
|
||||
return 1 if saturation1 < saturation2 else 0
|
||||
|
||||
def calculate_brightness(image):
|
||||
# Convert the image to grayscale mode
|
||||
grayscale_image = image.convert("L")
|
||||
def decrease_brightness(image1_path: str, image2_path: str) -> float:
|
||||
def calculate_brightness(image):
|
||||
# Convert the image to grayscale mode
|
||||
grayscale_image = image.convert("L")
|
||||
|
||||
# Get the image data
|
||||
pixels = list(grayscale_image.getdata())
|
||||
# Get the image data
|
||||
pixels = list(grayscale_image.getdata())
|
||||
|
||||
brightness = sum(pixels) / len(pixels)
|
||||
return brightness
|
||||
brightness = sum(pixels) / len(pixels)
|
||||
return brightness
|
||||
|
||||
def decrease_brightness(image1_path, image2_path):
|
||||
image1 = Image.open(image1_path)
|
||||
image2 = Image.open(image2_path)
|
||||
|
||||
@@ -65,12 +63,9 @@ def decrease_brightness(image1_path, image2_path):
|
||||
return 1 if brightness1 > brightness2 else 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 输入两张图片的路径
|
||||
image1_path = "../Downloads/1.png"
|
||||
image2_path = "../Downloads/edited_darker.png"
|
||||
|
||||
# 比较图片亮度
|
||||
decrease_brightness(image1_path, image2_path)
|
||||
|
||||
# 比较图片饱和度
|
||||
|
||||
increase_saturation(image1_path, image2_path)
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
"parameters": {
|
||||
"files": [
|
||||
{
|
||||
"url": "https://drive.usercontent.google.com/download?id=1SIvX9Wimyw6i2UvnoLTNDHIObvDLAsIM&export=download&authuser=0&confirm=t&uuid=a48447ab-13a2-421f-9662-6ffff8f6f6d5&at=APZUnTVRxofs822XxgEv33WwYCkb:1705046264363",
|
||||
"path": "Desktop/1.png"
|
||||
"url": "",
|
||||
"path": "Desktop/2.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
{
|
||||
"type": "open",
|
||||
"parameters": {
|
||||
"path": "Desktop/View_Person_Organizational_Summary.docx"
|
||||
"path": "Desktop/2.png"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -28,15 +28,15 @@
|
||||
],
|
||||
"evaluator": {
|
||||
"func": "increase_saturation",
|
||||
"expected": {
|
||||
"type": "cloud_file",
|
||||
"path": "",
|
||||
"dest": "edited_colorful.png"
|
||||
},
|
||||
"result": {
|
||||
"type": "vm_file",
|
||||
"path": "Desktop/1.png",
|
||||
"dest": "1.png"
|
||||
},
|
||||
"expected": {
|
||||
"type": "vm_file",
|
||||
"path": "Desktop/edited_colorful.png",
|
||||
"dest": "edited_colorful.png"
|
||||
"path": "Desktop/2.png",
|
||||
"dest": "2.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
{
|
||||
"type": "open",
|
||||
"parameters": {
|
||||
"path": "Desktop/View_Person_Organizational_Summary.docx"
|
||||
"path": "Desktop/1.png"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -28,15 +28,15 @@
|
||||
],
|
||||
"evaluator": {
|
||||
"func": "decrease_brightness",
|
||||
"expected": {
|
||||
"type": "cloud_file",
|
||||
"path": "https://drive.usercontent.google.com/download?id=1M7T5iPv0kWvmZBbdTcRdG45zIpHMtrBn&export=download&authuser=0&confirm=t&uuid=d95db1f8-27dc-4532-9976-ea99c293f53e&at=APZUnTXfpgNCtXDtlqd55LgmrIAj:1705048270986",
|
||||
"dest": "edited_darker.png"
|
||||
},
|
||||
"result": {
|
||||
"type": "vm_file",
|
||||
"path": "Desktop/1.png",
|
||||
"dest": "1.png"
|
||||
},
|
||||
"expected": {
|
||||
"type": "vm_file",
|
||||
"path": "Desktop/edited_darker.png",
|
||||
"dest": "edited_darker.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user