ToRGBA - Maple Help

ImageTools

 ToRGBA
 convert an image to RGBA

 Calling Sequence ToRGBA( img, opts )

Parameters

 img - Image; input image opts - (optional) equation(s) of the form option = value; specify options for the ToRGBA command

Options

 • output = ColorImage
 Specifies a data structure into which the output is written. This can be used to avoid allocating memory. The height, width, and order must match that of the input. The dimensions of the output image are adjusted so that the row and column indices match the input. The default is NULL.

Description

 • The ToRGBA command converts grayscale, RGB, and RGBA images to RGBA images. This can be useful if a grayscale image is to be combined with an RGBA image, or to add an alpha layer to an RGB image.
 • The img parameter is the image to convert.
 • If img is of type GrayImage, a new image is created with each color layer identical to the input image (the alpha layer is assigned zero).
 • If img is of type ColorImage, a new image is created with each color layer identical to the corresponding layer of the input (the alpha layer is assigned zero).
 • If img is of type ColorAImage, the image is returned.

Examples

 > $\mathrm{with}\left(\mathrm{ImageTools}\right):$

Create a color image.

 > $\mathrm{imgc}≔\mathrm{Create}\left(100,200,\left[r↦\frac{r}{100},\left(r,c\right)↦\mathrm{abs}\left(\mathrm{sin}\left(\frac{r}{100.}\right)\right),\left(r,c\right)↦\mathrm{exp}\left(-\frac{c}{100.}\right)\right]\right):$

Convert to RGBA.

 > $\mathrm{imga}≔\mathrm{ToRGBA}\left(\mathrm{imgc}\right):$

Generate a gray mask from the color image.

 > $\mathrm{mask}≔\mathrm{ToRGBA}\left(\mathrm{ToGrayscale}\left(\mathrm{imga}\right)\right):$

Average it with the original image.

 > $\mathrm{desat}≔\frac{\mathrm{imga}+\mathrm{mask}}{2}:$
 > $\mathrm{Embed}\left(\left[\mathrm{imga},\mathrm{mask},\mathrm{desat}\right]\right)$