RGBtoHSV - Maple Help

ImageTools

 RGBtoHSV
 convert an RGB color image to an HSV color image

 Calling Sequence RGBtoHSV(img, opts)

Parameters

 img - ColorImage or ColorAImage; input image opts - (optional) equation(s) of the form option = value; specify options for the RGBtoHSV command

Options

 • inplace = truefalse
 Specifies whether the operation is performed in-place. This can be used to avoid allocating memory. The default is false.
 • output = Image
 Specifies a data structure into which the output is written. This can be used to avoid allocating memory. The size and number of layers 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 RGBtoHSV command converts a color image with an RGB color representation to an HSV color representation.
 • The img parameter is the input image and must be of type ColorImage or ColorAImage.

Examples

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

Create three monochromatic images representing the RGB layers and then combine them into a single color image.

 > $\mathrm{img_r}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦\mathrm{evalf}\left(0.5\cdot \mathrm{sin}\left(\left(0.005+0.003\cdot c\right)\cdot c\right)\cdot \left(0.5+0.5\cdot \mathrm{sin}\left(0.15\cdot r\right)\right)\right),'\mathrm{fit}'\right):$
 > $\mathrm{img_g}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦\mathrm{evalf}\left(\mathrm{exp}\left(-\frac{c}{50}\right)\cdot 0.5\cdot \mathrm{sin}\left(\frac{r}{20}\right)\right),'\mathrm{fit}'\right):$
 > $\mathrm{img_b}≔\mathrm{Create}\left(100,200,\left(r,c\right)↦\mathrm{evalf}\left(\frac{c}{100}\right),'\mathrm{fit}'\right):$
 > $\mathrm{img_rgb}≔\mathrm{CombineLayers}\left(\mathrm{img_r},\mathrm{img_g},\mathrm{img_b}\right):$

Convert the color image to an HSV representation and then extract each layer as a separate monochromatic image.

 > $\mathrm{img_hsv}≔\mathrm{RGBtoHSV}\left(\mathrm{img_rgb}\right):$
 > $\mathrm{img_h}≔\mathrm{GetLayer}\left(\mathrm{img_hsv},1\right):$
 > $\mathrm{img_s}≔\mathrm{GetLayer}\left(\mathrm{img_hsv},2\right):$
 > $\mathrm{img_v}≔\mathrm{GetLayer}\left(\mathrm{img_hsv},3\right):$

Display the original RGB layers, the color image, and the HSV layers.

 > $\mathrm{Embed}\left(\left[\mathrm{img_r},\mathrm{img_g},\mathrm{img_b}\right]\right)$

 > $\mathrm{Embed}\left(\mathrm{img_rgb}\right)$

 > $\mathrm{Embed}\left(\left[\mathrm{img_h},\mathrm{img_s},\mathrm{img_v}\right]\right)$