'Calculate average pixel intensity for each frame of tif movie

I imported a tif movie into python which has the dimensions (150,512,512). I would like to calculate the mean pixel intensity for each of the 150 frames and then plot it over time. I could figure out how to calculate the mean intensity over the whole stack (see below), but I am struggling to calculate it for each frame individually.

from skimage import io

im1 = io.imread('movie.tif')


print("The mean of the TIFF stack is:")
print(im1.mean())

How can I get the mean pixel intensities for each frame?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source