1 of 2

There is no perfect solution to the problem you face. You must make a choice and every choice has pros and cons. For example you can apply saturation thresholding. Or you can use normalization. Saturation clipping is very simple to realize and provide excellent performance provided that processing stages will not overflow the intensities too much from 255 (or 0). Otehrwise, it will severely distort the image. Normazlation guarantiees a loss free output but my severely degrade the algorthm quality. Besides it requires you to know in advance the perfect normalization scale, which may not be possible always.