After performing some processing in an array of audio or images, it must be normalized within the range before it can be written back to the file. This can be done like this:
# Normalize audio channels to between -1.0 and +1.0 audio[:,0] = audio[:,0]/abs(audio[:,0]).max() audio[:,1] = audio[:,1]/abs(audio[:,1]).max() # Normalize image to between 0 and 255 image = image/(image.max()/255.0)
Is there a way to do this in more detail, more convenient? matplotlib.colors.Normalize() does not seem to be relevant.
python arrays numpy scipy convenience-methods
endolith Nov 14 '09 at 17:52 2009-11-14 17:52
source share