I want to average a slice of a numpy array (its an image).
Currently i'm iterating over each pixel as follows but its dreadfully slow. I know there is a better way but I cant work it out. Its probably the numpy fancy indexing but i'm stuck.
I've used openCV to read the image into a numpy array with the shape 640,480,3 and I want to change the each of the last bit i.e [123,121,234] to the average of that slice for each of the 640x480.
You don't have to give me the answer but a shove in the right direction would be helpful.
This is whats slow for me:
def bw_image_arr(self):
for x in self.images:
for y in x:
for z in y:
z = z.mean()
.mean.