ImageArray.
rescale
(cmax=None, amax=None, inline=True)[source]¶Rescales the image to be in [0,1] range.
Parameters: | cmax: float, optional :
amax: float, optional :
inline: boolean, optional :
|
---|---|
Returns: | out: ImageArray :
|
Notes
This requires that the shape of the ImageArray to have a length of 3, and for the third dimension to be >= 3. If the third dimension has a shape of 4, the alpha channel will also be rescaled.
Examples
>>> im = np.zeros([64,128,4])
>>> for i in range(im.shape[0]):
... for k in range(im.shape[2]):
... im[i,:,k] = np.linspace(0.,0.3*k, im.shape[1])
>>> im = ImageArray(im)
>>> im.write_png('original.png')
>>> im.rescale()
>>> im.write_png('normalized.png')