Yes, as I said, maybe your images are of shape [channels, width, height] and not [width, height, channels]. Basically, the dimension having channels should be skipped while taking the mean. If the 1st dimension has channels, we can pass (0,2,3) to the mean function. If the 3rd dimension has channels, then we use (0,1,2) inside the mean function. Hope I made sense.