【发布时间】:2021-01-27 03:23:59
【问题描述】:
我正在尝试编写一个 darken_filter 和一个 change_picture 函数,将图像左半部分的像素修改为更暗。非常感谢您的帮助。这是我当前的代码:
# Constants for the image
IMAGE_URL = "https://codehs.com/uploads/e07cd01271cac589cc9ef1bf012c6a0c"
IMAGE_WIDTH = 280
IMAGE_HEIGHT = 200
DARKENING_FACTOR = 50
MIN_PIXEL_VALUE = 0
image = Image(IMAGE_URL)
image.set_position(70, 70)
image.set_size(IMAGE_WIDTH, IMAGE_HEIGHT)
add(image)
# This function should take a pixel and return a tuple
# with the new color
def darken_filter(pixel):
pass
# This function should loop through each pixel on the
# left hand side and call the darken filter to calculate
# the new color then update the color.
def change_picture():
pass
# Give the image time to load
print("Making Darker....")
print("Might take a minute....")
timer.set_timeout(change_picture, 1000)
【问题讨论】:
-
在这个社区中,我们不为您做这些工作,我们帮助您解决问题,所以您是否在您的两个功能中尝试过一些东西,或者您只是要求它?
-
问题是什么?你说“函数应该采用一个像素”,但你没有向我们定义你的“像素”是什么(eg:它是一个十六进制RGB值吗?一个整数? ,一个数组?,一个元组?)。你知道使用
For循环检查像素值吗?
标签: python python-imaging-library image-manipulation