Q:

Rescaling each image Individually with keras

I am a beginner working on a simple CNN to classify X-ray detector images. Due to source intensity, all images have different max values. I want to use ImageDataGenerator to rescale those images to be in range [0,1], but cant't find a way to do that for each individual image. As far as I understand it, people usually just divide by 255 because that is the RGB max, but in my case the max could be anything between 1 and serveral million. Does anyone have an idea how to do this within ImageDataGenerator? Thank you for your time!
Edit: 
I ran over my images and normalized all of them prior to feeding them to the generator. Inspecting them then showed that the generator had scaled them back to rgb values (I assume due to color_mode). I then used rescale with the standard 1./255 and got the expectd max value of 1. However, after adding back samplewise_std_normalization, I again am getting values larger than 1. I understand why this is happening, but I'm not sure which "rule" is more important to follow: normalize to [0,1] or use samplewise_std_normalization

A:

Normalize to $[0, 1]$ is what I'd do to ensure that the model gets expected (sanitized) inputs.
Using the samplewise_std_normalization is something that I'd do inside the model to highlight features.
E.g. a white pixel is more important in a mostly black image than in a noisy image.

