lvcrgbhsv(3)

LIBRARY ROUTINE
lvcrgbhsv - Conversion between NTSC RGB and HSV color spaces.

LIBRARY CALL
#include "vinclude.h"
int
lvcrgbhsv(img1, type, type_flg, norm, norm_flg)
struct xvimage *img1;
int type, type_flg, norm_flg;
float norm;

INPUT

img1
    input multispectral image of colormap model RGB or HSV.

type
    1 = conversion RGB to HSV

    0 = conversion HSV to RGB

type_flag
    if set, use the conversion specified by type

norm
    normalization factor

norm_flag
    normalization flag. If set, use norm as the normalization factor otherwise, default normalization is set to 255

OUTPUT

img1
    converted image of type FLOAT normalized between 0 and 1.

MODIFICATIONS

DESCRIPTION
lvcrgbhls converts from a multispectral image of color space model RGB to HSV and vice versa. The RGB image is assumed to be of type NTSC or generic. Generic RGB is an image that is RGB but can not legally be classified as NTSC. This routine needs to work with an image normalized between 0 and 1. If norm_flg is set, then use the value norm to normalize the input image. Otherwise, default normalization value is 255. The routine sets the zero degree hue to be red, with green and blue following in counter clockwise direction. When converting from RGB to HSV, any time that the saturation is 0 (grey level), hue is undefined and is therefore set to 0 (red). This may degrade the image. When converting from HSV to RGB, any time a saturation of zero is encountered, the R,G, and B data are all assigned the value of V (result is a gray level).

The algorithm which transforms from RGB to HSV and HSV to RGB was taken from Foley & VanDam (Fundamentals of Interactive Computer Graphics), (with our modifications).

This routine will not touch the data map; therefore, the data map may be invalid after performing the conversion.

DIAGNOSTICS
Variable img1 is the input multispectral image of colormap model RGB or HSV of data type FLOAT.

Variable type is used for conversion from RGB to HSV. If type = 1, conversion is from RGB to HSV. If type = 0, conversion is from HSV to RGB. If variable type_flg is set, use the conversion specified by type.

The variable norm is a normalization factor since the data must be normalized between zero and one. If variable norm_flg is set, use the normalization factor specified by norm. Otherwise, use the default normalization factor of 255.

Variable img1 is used as the input image and the output image. Care must be taken not to overwrite important image data.

lvcrgbhls returns a 1 upon success and a 0 upon failure.

SEE ALSO
vcrgbhsv(1), intro(3), vipl(3), verror(3), vutils(3)

RESTRICTIONS
vcrgbhsv must have an input image of data storage type FLOAT and the input image color map model must be of type genericRGB, ntscRGB or HSV.

AUTHOR
Tom Sauer

COPYRIGHT
Copyright 1991, University of New Mexico. All rights reserved.