聲明:我是編程新手。 下面的代碼不起作用,因爲它似乎功能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也存在(作爲全局聲明)。 –