Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_HSV2RGB_(H, S, V, R, G, B) into cvblob.cpp #12

Closed
GoogleCodeExporter opened this issue Feb 25, 2016 · 1 comment
Closed

_HSV2RGB_(H, S, V, R, G, B) into cvblob.cpp #12

GoogleCodeExporter opened this issue Feb 25, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. on cvblob.cpp


What is the expected output? What do you see instead?
I have a warning : 
">.\cvBlob\cvblob.cpp(285) : warning C4244: 'initialisation' : conversion de 
'double' en 'int', perte possible de données".
So I add a cast : int _hf = (int)floor(_h);

I think so, you can delete a line, because : 
int _hf = (int)floor(_h);
int _hi = ((int)_h)%6; (delete this line?)
have same result, (to my mind), see http://www.alvyray.com/Papers/hsv2rgb.htm

What version of the product are you using? On what operating system?
v0.10.1

Please provide any additional information below.

  ///////////////////////////////////////////////////////////////////////////////////////////////////
  // Based on http://en.wikipedia.org/wiki/HSL_and_HSV
  // see also http://www.alvyray.com/Papers/hsv2rgb.htm
  // hue: H -> [0, 360] ; saturation: S -> [0, 1] ; value: V -> [0, 1]

  /// \def _HSV2RGB_(H, S, V, R, G, B)
  /// \brief Color translation between HSV and RGB.
#define _HSV2RGB_(H, S, V, R, G, B) \
  { \
    double _h = H/60.; \
    int _hf = (int)floor(_h); \ //I add the cast (int)
    int _hi = ((int)_h)%6; \    //_hi=_hf ... //no need _hi... (delete?)
    double _f = _h - _hf; \
    \
    double _p = V * (1. - S); \
    double _q = V * (1. - _f * S); \        //if _hf is odd
    double _t = V * (1. - (1. - _f) * S); \ //if _hf is even
    \
    switch (_hf) \ //switch (_hi)
    { \
      case 0: \
          R = 255.*V; G = 255.*_t; B = 255.*_p; \
      break; \
      case 1: \
          R = 255.*_q; G = 255.*V; B = 255.*_p; \
      break; \
      case 2: \
          R = 255.*_p; G = 255.*V; B = 255.*_t; \
      break; \
      case 3: \
          R = 255.*_p; G = 255.*_q; B = 255.*V; \
      break; \
      case 4: \
          R = 255.*_t; G = 255.*_p; B = 255.*V; \
      break; \
      case 5: \
          R = 255.*V; G = 255.*_p; B = 255.*_q; \
      break; \
    } \
  }
  ///////////////////////////////////////////////////////////////////////////////////////////////////

Original issue reported on code.google.com by mathias....@gmail.com on 12 Jul 2010 at 9:52

@GoogleCodeExporter
Copy link
Author

Hi mathias.ferraton,

I've added the "int" casting to the repository but I don't have deleted the 
line of the module. I prefer to leave that line because it allows more freedom 
in the input. In other case I think "H" is restricted to [0, 360] (correct me 
if I'm wrong). Although I do not need this feature now :-S

Thank you very much Mathias for your help!

Original comment by grendel....@gmail.com on 14 Jul 2010 at 8:58

  • Changed state: Fixed
  • Added labels: OpSys-All, Type-Enhancement, Usability
  • Removed labels: Type-Defect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant