3
$\begingroup$

In Mathematica, Hue[h,s,b] uses HSB colors. However, unlike anything I've ever seen, the h, s, and b have to be between 0 and 1. The trouble is that I am trying to use Mathematica to take NSB colors out of an image and pass them to another program, so I need my h to be between 0 and 360 (Which is believe is the standard way) and s and b to be between 0 and 100.

How can I convert Mathematica's HSB to what I described?

$\endgroup$
1
  • $\begingroup$ Just multiply the MMA values by 360/100/100 to go out, or divide by same to go in, or am I missing something? $\endgroup$
    – ciao
    May 22, 2016 at 0:07

1 Answer 1

5
$\begingroup$

You can write your own converter like so:

hue2HSB[color : Hue[h_, s_, b_]] := {360. h, 100. s, 100. b}

then

Hue[0.55, 0.73, 0.82]

hue

coversion

The next step would be to export the conversion, but since you don't indicate how you plan to do that, I can't say anything more.

$\endgroup$
2
  • $\begingroup$ Thank you! To expand on this, I have a list of lists of colors. How would I apply this function to each of the colors without loops? $\endgroup$
    – user40421
    May 22, 2016 at 0:45
  • 2
    $\begingroup$ @user40421. Look up Map; it is the usual function for applying a function to a list of values. $\endgroup$
    – m_goldberg
    May 22, 2016 at 0:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.