RGB空间与HSI空间的转换算法的C++实现
typedef struct
{
BYTE red; // [0,255]
BYTE green; // [0,255]
BYTE blue; // [0,255]
}COLOR_RGB;
typedef struct
{
float hue;
float saturation;
float intensity;
}COLOR_HSI;
// Converts RGB to HSI
static void RGBtoHSI(/*[in]*/const COLOR_RGB *rgb, COLOR_HSI *hsi)
{
double pi=3.1415926;
double r=(rgb->red / 255.0);
double g=(rgb->green / 255.0);
double b=(rgb->blue / 255.0);
double theta = acos(0.5 * ((r - g) &
typedef struct
{
BYTE red; // [0,255]
BYTE green; // [0,255]
BYTE blue; // [0,255]
}COLOR_RGB;
typedef struct
{
float hue;
float saturation;
float intensity;
}COLOR_HSI;
// Converts RGB to HSI
static void RGBtoHSI(/*[in]*/const COLOR_RGB *rgb, COLOR_HSI *hsi)
{
double pi=3.1415926;
double r=(rgb->red / 255.0);
double g=(rgb->green / 255.0);
double b=(rgb->blue / 255.0);
double theta = acos(0.5 * ((r - g) &