How to grayscale a photo using the aggregate mean of the array?

Viewed 29

I have been tasked with applying the mean aggregation function to find the average of values across different channels in my photo and putting the result in new array.

What ends up happening is that I get a big gray photo instead of a grayscale photo.

I think I need to find the mean of each channel but am unsure of how to proceed.

Here is my code I have.

New_Greece_Gray_Scale = np.array(mpimg.imread('Greece.jpg'))
print("Total mean:", New_Greece_Gray_Scale.mean())

New_Greece_Gray_Scale[:,:,0] = 161.93223291599233
New_Greece_Gray_Scale[:,:,1] = 161.93223291599233
New_Greece_Gray_Scale[:,:,2] = 161.93223291599233

fig, ax = plt.subplots(figsize=(12, 18))
ax.imshow(New_Greece_Gray_Scale)
ax.set(xticks=[], yticks=[])

plt.show()

Greece_image.shape
0 Answers
Related