声明:我是编程新手。 下面的代码不起作用,因为它似乎功能1输出没有传递到功能2.返回函数的值到另一个函数python
def img_to_color(path_file):
# takes an image and calculates avg red/green/blue value
color_avg = [red, green, blue]
return color_avg
def extract_RGB(path_folder):
j = 0
RGB = []
file_count = len(os.listdir(path_folder))
files = os.listdir(path_folder)
while j < file_count:
img_to_color(path_folder + "/" + files[j])
RGB.append(color_avg)
j = j+1
X_training.append(trainingDataFolder(pfad, RGB))
img_to_color工作,但RGB停留[]即使我调用该函数的功能。
什么是'X_training'?在哪里宣布? “红”,“绿”和“蓝”也一样。 –
我排除了红色,绿色和蓝色的计算,使其更短。此功能正常工作。 X_training也存在(作为全局声明)。 –