Please forgive me if this is the wrong forum. I am not quite sure under which heading this particular problem falls. Mods, please move it if it is not in the correct place. Thanks.

OK, I wonder if some bright mathematician can help me with a PHP programming problem please?

Let me explain. Greys in a black and white image are in the range 0-255. These are the only possible values. Each greyscale pixel has a value in this range.

I have an image where the range is quite narrow (57-205) and I want to re-distribute it throughout the scale(0-255) in as even way as possible. I am writing a program to re-allocate these values and I would like help in working out a formula or formulas to achieve this.

Can anyone work out a formula or a couple of formulas to allow me to re-distribute these values over the full range please. It does not matter if there are spaces without values, but I would like a nice relatively even spread if possible.

Thank you so much for any super-duper mathematical solutions. As you can tell, I am not great at maths. :-)

Thanks for your help.

Paul