I'm working with a dataset of grayscale images (values ranging from [0,1]) and would like the average pixel intensity of each image to be the same (let's say 0.5). However, a simple multiplication would cause the range of pixels in the image to go out of the range [0,1].
If I'm correct, there are many ways to modify the pixels so that the mean is a desired value, but I'm looking for something that subjectively wouldn't change the appearance of the image too much (other than making it slightly lighter/darker). When I think "make sure the values are within a certain range", I think of a sigmoid function, but I'm not quite sure how to apply it to the task at hand.
Any guidance or ideas would be greatly appreciated! Thanks.
(not a homework question btw, just a side project)