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); }
/** * 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); }