コード例 #1
0
float	retrieve_normalised_hue(unsigned int r, unsigned int g, unsigned int b)
{
	float hue;
	if (b <= g)
	{
		hue = retrieve_theta(r, g, b);
	}
	else
	{
		hue = (2 * M_PI) - retrieve_theta(r, g, b);
	}

	return hue * 255 / (2 * M_PI);
}
コード例 #2
0
ファイル: ihls.cpp プロジェクト: AADC-Fruit/AADC_2015_FRUIT
/**
 * Calculating the hue value based on the blow formula:
 *
 * H = θ if B <= G
 * H = 2 * pi − θ if B > G
 *
 * The return value is normalised between 0 to 255.
 */
tFloat32
retrieve_normalised_hue(tUInt r, tUInt g, tUInt b)
{
    tFloat32 hue;
    if (b <= g)
    {
        hue = retrieve_theta(r, g, b);
    }
    else
    {
        hue = (2 * M_PI) - retrieve_theta(r, g, b);
    }

    return hue * 255 / (2 * M_PI);
}