ImageArray.
add_background_color
(background='black', inline=True)[source]¶Adds a background color to a 4-channel ImageArray
This adds a background color to a 4-channel ImageArray, by default doing so inline. The ImageArray must already be normalized to the [0,1] range.
Parameters: | background: :
inline: boolean, optional :
|
---|---|
Returns: | out: ImageArray :
|
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.,10.*k, im.shape[1])
>>> im_arr = ImageArray(im)
>>> im_arr.rescale()
>>> new_im = im_arr.add_background_color([1.,0.,0.,1.], inline=False)
>>> new_im.write_png('red_bg.png')
>>> im_arr.add_background_color('black')
>>> im_arr.write_png('black_bg.png')