I am working with images in numpy and at some point I scale an image.
import scipy.misc as msc
import numpy as np
...
img_rgb = msc.imread(img_fn)
im_scaled = img_rgb * factor
The result sometimes looks ugly with bright regions showing black spots. This seems to be caused by numerical overflow of the 8bit image RGB pixel. Is there a way to apply a ceiling operator such that if the multiplication would be > 255 it is clipped to 255. (I am not interested in a floor function as I don't expect signal to become negative)
I know I can test every pixel in a loop, but the would not be following the numpy philosophy of array handling.
Any help is much appreciated.
Thanks, Gert