yt.data_objects.image_array.ImageArray.rescale

ImageArray.rescale(cmax=None, amax=None, inline=True)[source]

Rescales the image to be in [0,1] range.

Parameters:

cmax: float, optional :

Normalization value to use for rgb channels. Defaults to None, corresponding to using the maximum value in the rgb channels.

amax: float, optional :

Normalization value to use for alpha channel. Defaults to None, corresponding to using the maximum value in the alpha channel.

inline: boolean, optional :

Specifies whether or not the rescaling is done inline. If false, a new copy of the ImageArray will be created, returned. Default:True.

Returns:

out: ImageArray :

The rescaled ImageArray, clipped to the [0,1] range.

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')