I have written the following function to normalize images to the range [0, 1]:
def normalize(image): bn, kn, h, w = image.shape image = image.view(bn, kn, -1) image -= image.min(2, keepdim=True) image /= image.max(2, keepdim=True) image = image.view(bn, kn, h, w) return image
Unfortunately this makes images darker, as can be seen here:
The first one is before and the second one after normalization. How can that be?