![]() | This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | ← | Archive 4 | Archive 5 | Archive 6 |
I just research a long time to get the key of HSV .I just submit my result here. I think many people need to understand the idea about color spaces and modules. although it somewhat hard to imagine the gemoetry module ,but at last I got it . I hope to help those who are not clear about this porblem.
In order to prove why chroma is defined as “C=max-min”, I intended to give a diagram to show the principle as below.
Any color like RGB(max,mid,min) can be changed to (max-min,mid-min,0) then change it to standard hue color like (255, (mid-min)/(max-min)*255,0). It is more easy to understand why hue’s formula is like this.
qduwg@163.com
Can’t X(H prime) be simplified? Isn't the same as ? Yurivict ( talk) 00:16, 4 April 2012 (UTC)
I don't know why here H' mode 2? I think it is not symmetrical derivation progress to the definition HSV's H component. Please explain why? I calculate the X (here i define varible "mid" as X)according to the definition formula like this(e.g R is max):
H'=(mid-min)/(max-min) min=V(1-S) max=V, so we can get mid=V-C+H'C, then we write the last result :(MAX,MID,MIN) =(V,V-C+H'C,V-C),SO,each component can sub the MIN, we get (C,H'C,0).
How we can decide X=H'C need to be written as X=C(1-|H'MOD 2 -1|)?? WHAT'S THE PURPOSE writing like this?
thank you! — Preceding unsigned comment added by Qduwg ( talk • contribs) 07:27, 30 January 2013 (UTC)
Dusting off an old memory here.
If you do a google *image* search on "HSB color model", you'll see that there are many references to HSB as the single cone model. In other words, "Brightness" is strictly the distance from black. Full brightness does not collapse to decreased saturation as it does with HSL. Not full saturation at halfway up.
(Not my image....:) http://albertociammaricone.files.wordpress.com/2010/09/color_hsb.jpg
FWIW, this is also what the original Adobe postscript specification indicates. In fact, I would have sworn that I've seen HSV as the double cone model before, but I can't seem to find my eons old original Foley & Van Damme to verify if this is where I saw it (if anyone has one, I'd love to see what it says). Thanks for humoring me! :) Tgm1024 ( talk) 13:21, 24 June 2013 (UTC)
In the machinevision/image processing/video processing software called RoboRealm, you will find that that its Hue wraparound point (360deg to 0deg point) is aligned with the Blue channel, as opposed to the Red channel shown in the Wikipedia article here. Is this a valid implementation of HSV and HSL? Or is it incorrect? If it's not correct, I'm not sure if they've fixed it yet, as I'm using and sticking to using the free but much older version of the software (the most recent versions are commercial software, the older version I have was distributed as freeware). But yeah, I'm not sure if having it wraparound on blue is actually considered a "bad" implementation or not. Animedude5555 ( talk) 00:53, 24 August 2013 (UTC)
User:Jacobolus reverted my recent edit, saying in his edit summary: „the former numbers were deliberate: these are the ones in common use for this color model in software packages [and now e.g. proposed as web standards]“. It’s about former
versus
from the sRGB and Rec. 709 articles. (I have not checked the actual specifications.)
Since the latter would be consistent with other articles, I’d like the rounded values to be better sourced (Adobe?). In my humble opinion, WP articles should prefer precise values even if they are only used in theory, not practice. They shouldn’t be too verbose in supplementary articles, though, but 4 sigfigs aren’t.
I don’t know which particular web standards are meant (SVG, CSS, HTML …?). They usually just reference sRGB (or maybe scRGB), but I found an instance of actual values in filter effects, although either rounded to 3 sigfigs (neither 2 nor 4) or off:
Further research shows that the 2-digit approximations for Rec. 601 (NTSC) values in the article are what Adobe products are using and, as a sidenote, UHDTV uses different values:
— Christoph Päper 19:02, 9 September 2013 (UTC)
Hi Materialscientist. I’m curious why you think it’s better to skip the parenthesized years in pointers to “Further reading” sources, why you want to rename “Further reading” to “Bibliography”, why you want to increase the number of footnotes listed after several paragraphs when the previous ones were perfectly fine at linking to the proper places, why you want to remove ending page numbers from pointers to journal articles, why you want to remove some of the pointers to further reading sources, why you want to remove all the line breaks from inside footnotes, etc. As far as I can tell every one of these changes makes the references uglier and harder to follow, makes the overall formatting inconsistent, and is a basically completely unnecessary change, just churn for the sake of churn, edits for the sake of making edits. But there’s perhaps some benefit I’m not seeing? Cheers. – jacobolus (t) 08:40, 20 September 2013 (UTC)
I tried to edit something here to fix something I thought was in error, but now I think something is missing. There appears to be a large white gap this wiki article, where I believe there was some text before. Benhut1 ( talk) 13:59, 21 January 2014 (UTC)
The description of hue, where it describes the transformation as warping hexagons into circles. Maybe I'm not looking at it from the right point of view, but it seems to me that it is actually warping circles into hexagons. From my understanding, the HSL, HSV, and HSI color spaces are defined in terms of cylinders or cones, who's cross-sections are circles, not hexagons. As such, any color in one of these HS color spaces can (for any given value of L, V, or I) be thought of as being a particular point on a circular plane. However, since computer monitors are RGB devices, in order to properly represent an HSL, HSV, or HSI color in RGB color space, the circles of the HSL, HSV, or HSI color space must be first converted into hexagons in RGB color space (these hexagons are in fact cross-sections of tilted cubes, where the cube is the RGB color space cube). Therefore, calling the transformation a circle to hexagon transformation is most appropriate for talking about representing the HSL, HSV, or HSI color space in the RGB color space. I believe the description of the transformation as hexagon to circle, as stated by the writer of this article, is in fact a mistake. I made the change to the article a couple months ago, but since then Jacobolus (a Wikipedia moderator) reverted it back to the mistaken version that I previously had corrected! The only reason I asked for the edit to be reverted was to fix what I believe I broke on the page, not for the whole article to be reverted to its previous state! Benhut1 ( talk) 01:45, 17 March 2014 (UTC)
I believe there is a mistake in the formulas for converting back to RGB. In determining the intermediate values, the first piece-wise definition states that these values are all 0 when H is undefined. But, according to the formulas presented in this section, H can never be undefined (if chroma is ever 0, then both Hue and Saturation are set to 0 according to the conversion formulas for RGB to HSL). Would it not be more accurate to say that if chroma is 0, then these component values should all be 0? The corrected formula would then be defined as:
Now that I've studied this article further, it appears that the reference to "if H is undefined" is being referenced from the conversion of RGB to HSL, where, if chroma is 0, then hue is undefined. However, it is noted that for convenience, when hue is undefined, it is generally just set to 0. So for computational purposes, when converting from RGB to HSL, if the calculated value of chroma is zero, you can short circuit much of the computations and merely set hue and saturation to zero. All that's left to calculate then, is the lightness. Conversely, converting such an HSL color back to RGB, chroma would again be calculated as zero, and for efficiency, hue and saturation can simply be assigned 0. And all that's left is determining the amount of lightness to add to each of the R, G, and B components (the quantity in the HSL to RGB conversion formulas). Fourpastmidnight ( talk)
Here is some C code for HLC to RGB and back Though it is unclear to me if the Hexagon approach is more accurate !!??
A little later: I've read the article more thoroughly and the projection of the RGB cube on to the chroma/hue plane is a hexagon so the hexagonal computation is more accurate. — Preceding unsigned comment added by 108.89.37.1 ( talk) 00:45, 24 February 2015 (UTC)
#define DEGREES_TO_RADIANS (3.1415926 / 180.0)
#define TWO_OVER_ROOT_THREE (2.0 / sqrt(3.0))
#define ONE_OVER_ROOT_THREE (1.0 / sqrt(3.0))
#define LIMIT_CLAMP(lowerlimit, x, upperlimit) \
if((x) > (upperlimit)) (x) = (upperlimit); \
else if((x) < (lowerlimit)) (x) = (lowerlimit)
void RGB_to_HLC(uint8_t r, uint8_t g, uint8_t b, double *hue, double *luma, double *chroma)
{
double alpha, beta;
alpha = (2.0 * r - g - b) / 2.0 / 255.0;
beta = (g - b) / TWO_OVER_ROOT_THREE / 255.0;
*luma = (r * 0.21 + g * 0.72 + b * 0.07) / 255.0; // 0.0 to 1.0 (sRGB Y'709)
*hue = atan2(beta, alpha) / DEGREES_TO_RADIANS; // 0° to 360°
if(*hue < 0) *hue += 360.0;
*chroma = hypot(alpha, beta); // 0.0 to 1.0
LIMIT_CLAMP(0, *hue, 360); LIMIT_CLAMP(0, *luma, 1); LIMIT_CLAMP(0, *chroma, 1);
}
void HLC_to_RGB(double hue, double luma, double chroma, uint8_t *r, uint8_t *g, uint8_t *b)
{
double alpha, beta, red, green, blue;
alpha = chroma * cos(hue * DEGREES_TO_RADIANS);
beta = chroma * sin(hue * DEGREES_TO_RADIANS);
blue = (luma - 0.21 * (alpha + beta * ONE_OVER_ROOT_THREE) - 0.72 * TWO_OVER_ROOT_THREE * beta);
green = ((blue + beta * TWO_OVER_ROOT_THREE));
red = ((blue + alpha + beta * ONE_OVER_ROOT_THREE));
LIMIT_CLAMP(0, red, 1); LIMIT_CLAMP(0, green, 1); LIMIT_CLAMP(0, blue, 1);
red *= 255.0; green *= 255.0; blue *= 255.0;
*r = (uint8_t)red; *g = (uint8_t)green; *b = (uint8_t)blue;
}
Clive McCarthy — Preceding unsigned comment added by CliveMcCarthy ( talk • contribs) 21:21, 23 February 2015 (UTC)
Is this the same as Mod(H', 2) (reminder from division H' by 2 ?) ?
And | means absolute value ?
Conversion HSV to RGB using method from this article works well in VBA, but this part with mod2 changes result only a little if modified and it is difficult to say wahat this is - Mod(H', 2), Mod(H', -1) or something else. In one case Mod(H', -1) gave incorrect result, Mod(H', 2) always gaves correct color values. By the way - colors (R, G, B) should by multiplied by 255 if someone wants them in most popular form.
Thanks
Darekk2 (
talk)
19:46, 7 June 2015 (UTC)
I attempted to write the code.
def hsv2rgb(hsv):
#
/info/en/?search=HSL_and_HSV
# -------------------------------------------
# pull them aside for sanity's sake
# -------------------------------------------
hue = float(hsv[0])
saturation = (float(hsv[1]) / 100.0)
value = (float(hsv[2]) / 100.0)
# -------------------------------------------
# get chroma
# -------------------------------------------
chroma = value * saturation
# -------------------------------------------
# Revert hue to hue prime
# -------------------------------------------
hue = hue / 60.0
# -------------------------------------------
# find second highest value
# -------------------------------------------
midling = chroma * (1 - abs((hue % 2) - 1))
# -------------------------------------------
# find red, green, and blue primes
# -------------------------------------------
red = 0.0
green = 0.0
blue = 0.0
if (saturation == 0.0):
red = 0.0
green = 0.0
blue = 0.0
elif (hue < 1.0):
red = chroma
green = midling
blue = 0.0
elif (hue < 2.0):
red = midling
green = chroma
blue = 0.0
elif (hue < 3.0):
red = 0.0
blue = midling
green = chroma
elif (hue < 4.0):
red = 0.0
green = midling
blue = chroma
elif (hue < 5.0):
red = midling
green = 0.0
blue = chroma
elif (hue < 6.0):
red = chroma
green = 0.0
blue = midling
# -------------------------------------------
# add min value to each
# -------------------------------------------
min_rgb = value - chroma
red = red + min_rgb
green = green + min_rgb
blue = blue + min_rgb
# -------------------------------------------
# round the numbers to useful values for gimp
# -------------------------------------------
red = round(red * 255)
green = round(green * 255)
blue = round(blue * 255)
# -------------------------------------------
# That should be it!
# -------------------------------------------
return(red, green, blue)
Feel free to test this. The input is an HSV tuple, where Hue is from 0 to 360, Saturation is from 0 to 100, and Value is from 0 to 100.
The notable difference comes here:
elif (hue < 3.0):
red = 0.0
blue = midling
green = chroma
Which suggests that the piecewise definition should have one piece changed, from
To
I have omitted the irrelevant pieces for brevity as this is already running long.
Please review and advise. Greysondn ( talk) 23:59, 10 November 2015 (UTC)
I don't think the style of the Disadvantages and Other cylindrical-coordinate color models is warranted on this site. Examples: "Such perversities led Cynthia Brewer, expert in color scheme choices for maps and information displays, to tell the American Statistical Association: ..." "The creators of HSL and HSV were far from the first to imagine colors fitting into conic or spherical shapes..."
I strongly recommend moving these sections towards a more neutral point of view. -- mafutrct ( talk) 11:28, 29 September 2015 (UTC)
There is an interesting discussion here about how and why HSL and HSV are used differently. http://stackoverflow.com/a/17350333/330663 Basically, HSV models how objects are lit (and thus is useful to photographers), whereas HSL is useful to painters who want to pick or "input" colors from a palette. Is this discussed in a reliable source somewhere? SharkD Talk 06:54, 18 November 2016 (UTC)
Given the breadth of the scope of this article, would it be okay to merge HCL color space here? SharkD Talk 03:01, 15 November 2016 (UTC)
I added the American English templates to the article and talk pages. There was a mix used with the vast majority being American. I changed "colour" to "color" except in book and journal titles. I suspect they need to be checked since the one article I checked that had "generalised" in the title was actually published as "Generalized". User-duck ( talk) 20:44, 3 September 2017 (UTC)
Both on the internet and in all software I've ever used, HSL has, in short, stood for 'Hue Sat Lum', not 'Hue Sat Lig', so why is it that in this article HSL is said to be an acronym for 'Hue, Saturation, Lightness' rather than 'Hue, Saturation, Luma' (or luminosity I'm not sure on which one it is)? BenYaMan ( talk) 15:40, 22 April 2018 (UTC)
I thought "luminance" should only be used for objects that emit light, not for objects which reflect light? SharkD Talk 17:46, 6 September 2017 (UTC)
In many of the descriptions of conversions, the modulus operator is applied to real values. This is confusing as the modulo operator is typically considered to only apply to integers, but the algorithms are only correct if mod is taken to produce a real-valued remainder. Even a programmer reading some of the algorithms might assume the integer interpretation of mod, especially since hue is often converted to a number between 0 and 6. Just before adding this comment, I had to delete an attempt to convey a "fixed" HSV->RGB conversion in incredibly broken English which also contained many factually incorrect statements. Presumably the author had attempted to implement the algorithm from Wikipedia before finding that it didn't produce the expected result. AnalyticalEngine ( talk) 03:51, 27 August 2018 (UTC)
I have split off the "Cylindrical-coordinate color models" section into Color_model#Cylindrical-coordinate_color_models. I think the "Disadvantages" section could also be split off into an article that deals with "perceptual uniformity"/"perceptual relevance" more generally. ➧ datumizer ☎ 00:50, 11 September 2018 (UTC)
![]() | This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | ← | Archive 4 | Archive 5 | Archive 6 |
I just research a long time to get the key of HSV .I just submit my result here. I think many people need to understand the idea about color spaces and modules. although it somewhat hard to imagine the gemoetry module ,but at last I got it . I hope to help those who are not clear about this porblem.
In order to prove why chroma is defined as “C=max-min”, I intended to give a diagram to show the principle as below.
Any color like RGB(max,mid,min) can be changed to (max-min,mid-min,0) then change it to standard hue color like (255, (mid-min)/(max-min)*255,0). It is more easy to understand why hue’s formula is like this.
qduwg@163.com
Can’t X(H prime) be simplified? Isn't the same as ? Yurivict ( talk) 00:16, 4 April 2012 (UTC)
I don't know why here H' mode 2? I think it is not symmetrical derivation progress to the definition HSV's H component. Please explain why? I calculate the X (here i define varible "mid" as X)according to the definition formula like this(e.g R is max):
H'=(mid-min)/(max-min) min=V(1-S) max=V, so we can get mid=V-C+H'C, then we write the last result :(MAX,MID,MIN) =(V,V-C+H'C,V-C),SO,each component can sub the MIN, we get (C,H'C,0).
How we can decide X=H'C need to be written as X=C(1-|H'MOD 2 -1|)?? WHAT'S THE PURPOSE writing like this?
thank you! — Preceding unsigned comment added by Qduwg ( talk • contribs) 07:27, 30 January 2013 (UTC)
Dusting off an old memory here.
If you do a google *image* search on "HSB color model", you'll see that there are many references to HSB as the single cone model. In other words, "Brightness" is strictly the distance from black. Full brightness does not collapse to decreased saturation as it does with HSL. Not full saturation at halfway up.
(Not my image....:) http://albertociammaricone.files.wordpress.com/2010/09/color_hsb.jpg
FWIW, this is also what the original Adobe postscript specification indicates. In fact, I would have sworn that I've seen HSV as the double cone model before, but I can't seem to find my eons old original Foley & Van Damme to verify if this is where I saw it (if anyone has one, I'd love to see what it says). Thanks for humoring me! :) Tgm1024 ( talk) 13:21, 24 June 2013 (UTC)
In the machinevision/image processing/video processing software called RoboRealm, you will find that that its Hue wraparound point (360deg to 0deg point) is aligned with the Blue channel, as opposed to the Red channel shown in the Wikipedia article here. Is this a valid implementation of HSV and HSL? Or is it incorrect? If it's not correct, I'm not sure if they've fixed it yet, as I'm using and sticking to using the free but much older version of the software (the most recent versions are commercial software, the older version I have was distributed as freeware). But yeah, I'm not sure if having it wraparound on blue is actually considered a "bad" implementation or not. Animedude5555 ( talk) 00:53, 24 August 2013 (UTC)
User:Jacobolus reverted my recent edit, saying in his edit summary: „the former numbers were deliberate: these are the ones in common use for this color model in software packages [and now e.g. proposed as web standards]“. It’s about former
versus
from the sRGB and Rec. 709 articles. (I have not checked the actual specifications.)
Since the latter would be consistent with other articles, I’d like the rounded values to be better sourced (Adobe?). In my humble opinion, WP articles should prefer precise values even if they are only used in theory, not practice. They shouldn’t be too verbose in supplementary articles, though, but 4 sigfigs aren’t.
I don’t know which particular web standards are meant (SVG, CSS, HTML …?). They usually just reference sRGB (or maybe scRGB), but I found an instance of actual values in filter effects, although either rounded to 3 sigfigs (neither 2 nor 4) or off:
Further research shows that the 2-digit approximations for Rec. 601 (NTSC) values in the article are what Adobe products are using and, as a sidenote, UHDTV uses different values:
— Christoph Päper 19:02, 9 September 2013 (UTC)
Hi Materialscientist. I’m curious why you think it’s better to skip the parenthesized years in pointers to “Further reading” sources, why you want to rename “Further reading” to “Bibliography”, why you want to increase the number of footnotes listed after several paragraphs when the previous ones were perfectly fine at linking to the proper places, why you want to remove ending page numbers from pointers to journal articles, why you want to remove some of the pointers to further reading sources, why you want to remove all the line breaks from inside footnotes, etc. As far as I can tell every one of these changes makes the references uglier and harder to follow, makes the overall formatting inconsistent, and is a basically completely unnecessary change, just churn for the sake of churn, edits for the sake of making edits. But there’s perhaps some benefit I’m not seeing? Cheers. – jacobolus (t) 08:40, 20 September 2013 (UTC)
I tried to edit something here to fix something I thought was in error, but now I think something is missing. There appears to be a large white gap this wiki article, where I believe there was some text before. Benhut1 ( talk) 13:59, 21 January 2014 (UTC)
The description of hue, where it describes the transformation as warping hexagons into circles. Maybe I'm not looking at it from the right point of view, but it seems to me that it is actually warping circles into hexagons. From my understanding, the HSL, HSV, and HSI color spaces are defined in terms of cylinders or cones, who's cross-sections are circles, not hexagons. As such, any color in one of these HS color spaces can (for any given value of L, V, or I) be thought of as being a particular point on a circular plane. However, since computer monitors are RGB devices, in order to properly represent an HSL, HSV, or HSI color in RGB color space, the circles of the HSL, HSV, or HSI color space must be first converted into hexagons in RGB color space (these hexagons are in fact cross-sections of tilted cubes, where the cube is the RGB color space cube). Therefore, calling the transformation a circle to hexagon transformation is most appropriate for talking about representing the HSL, HSV, or HSI color space in the RGB color space. I believe the description of the transformation as hexagon to circle, as stated by the writer of this article, is in fact a mistake. I made the change to the article a couple months ago, but since then Jacobolus (a Wikipedia moderator) reverted it back to the mistaken version that I previously had corrected! The only reason I asked for the edit to be reverted was to fix what I believe I broke on the page, not for the whole article to be reverted to its previous state! Benhut1 ( talk) 01:45, 17 March 2014 (UTC)
I believe there is a mistake in the formulas for converting back to RGB. In determining the intermediate values, the first piece-wise definition states that these values are all 0 when H is undefined. But, according to the formulas presented in this section, H can never be undefined (if chroma is ever 0, then both Hue and Saturation are set to 0 according to the conversion formulas for RGB to HSL). Would it not be more accurate to say that if chroma is 0, then these component values should all be 0? The corrected formula would then be defined as:
Now that I've studied this article further, it appears that the reference to "if H is undefined" is being referenced from the conversion of RGB to HSL, where, if chroma is 0, then hue is undefined. However, it is noted that for convenience, when hue is undefined, it is generally just set to 0. So for computational purposes, when converting from RGB to HSL, if the calculated value of chroma is zero, you can short circuit much of the computations and merely set hue and saturation to zero. All that's left to calculate then, is the lightness. Conversely, converting such an HSL color back to RGB, chroma would again be calculated as zero, and for efficiency, hue and saturation can simply be assigned 0. And all that's left is determining the amount of lightness to add to each of the R, G, and B components (the quantity in the HSL to RGB conversion formulas). Fourpastmidnight ( talk)
Here is some C code for HLC to RGB and back Though it is unclear to me if the Hexagon approach is more accurate !!??
A little later: I've read the article more thoroughly and the projection of the RGB cube on to the chroma/hue plane is a hexagon so the hexagonal computation is more accurate. — Preceding unsigned comment added by 108.89.37.1 ( talk) 00:45, 24 February 2015 (UTC)
#define DEGREES_TO_RADIANS (3.1415926 / 180.0)
#define TWO_OVER_ROOT_THREE (2.0 / sqrt(3.0))
#define ONE_OVER_ROOT_THREE (1.0 / sqrt(3.0))
#define LIMIT_CLAMP(lowerlimit, x, upperlimit) \
if((x) > (upperlimit)) (x) = (upperlimit); \
else if((x) < (lowerlimit)) (x) = (lowerlimit)
void RGB_to_HLC(uint8_t r, uint8_t g, uint8_t b, double *hue, double *luma, double *chroma)
{
double alpha, beta;
alpha = (2.0 * r - g - b) / 2.0 / 255.0;
beta = (g - b) / TWO_OVER_ROOT_THREE / 255.0;
*luma = (r * 0.21 + g * 0.72 + b * 0.07) / 255.0; // 0.0 to 1.0 (sRGB Y'709)
*hue = atan2(beta, alpha) / DEGREES_TO_RADIANS; // 0° to 360°
if(*hue < 0) *hue += 360.0;
*chroma = hypot(alpha, beta); // 0.0 to 1.0
LIMIT_CLAMP(0, *hue, 360); LIMIT_CLAMP(0, *luma, 1); LIMIT_CLAMP(0, *chroma, 1);
}
void HLC_to_RGB(double hue, double luma, double chroma, uint8_t *r, uint8_t *g, uint8_t *b)
{
double alpha, beta, red, green, blue;
alpha = chroma * cos(hue * DEGREES_TO_RADIANS);
beta = chroma * sin(hue * DEGREES_TO_RADIANS);
blue = (luma - 0.21 * (alpha + beta * ONE_OVER_ROOT_THREE) - 0.72 * TWO_OVER_ROOT_THREE * beta);
green = ((blue + beta * TWO_OVER_ROOT_THREE));
red = ((blue + alpha + beta * ONE_OVER_ROOT_THREE));
LIMIT_CLAMP(0, red, 1); LIMIT_CLAMP(0, green, 1); LIMIT_CLAMP(0, blue, 1);
red *= 255.0; green *= 255.0; blue *= 255.0;
*r = (uint8_t)red; *g = (uint8_t)green; *b = (uint8_t)blue;
}
Clive McCarthy — Preceding unsigned comment added by CliveMcCarthy ( talk • contribs) 21:21, 23 February 2015 (UTC)
Is this the same as Mod(H', 2) (reminder from division H' by 2 ?) ?
And | means absolute value ?
Conversion HSV to RGB using method from this article works well in VBA, but this part with mod2 changes result only a little if modified and it is difficult to say wahat this is - Mod(H', 2), Mod(H', -1) or something else. In one case Mod(H', -1) gave incorrect result, Mod(H', 2) always gaves correct color values. By the way - colors (R, G, B) should by multiplied by 255 if someone wants them in most popular form.
Thanks
Darekk2 (
talk)
19:46, 7 June 2015 (UTC)
I attempted to write the code.
def hsv2rgb(hsv):
#
/info/en/?search=HSL_and_HSV
# -------------------------------------------
# pull them aside for sanity's sake
# -------------------------------------------
hue = float(hsv[0])
saturation = (float(hsv[1]) / 100.0)
value = (float(hsv[2]) / 100.0)
# -------------------------------------------
# get chroma
# -------------------------------------------
chroma = value * saturation
# -------------------------------------------
# Revert hue to hue prime
# -------------------------------------------
hue = hue / 60.0
# -------------------------------------------
# find second highest value
# -------------------------------------------
midling = chroma * (1 - abs((hue % 2) - 1))
# -------------------------------------------
# find red, green, and blue primes
# -------------------------------------------
red = 0.0
green = 0.0
blue = 0.0
if (saturation == 0.0):
red = 0.0
green = 0.0
blue = 0.0
elif (hue < 1.0):
red = chroma
green = midling
blue = 0.0
elif (hue < 2.0):
red = midling
green = chroma
blue = 0.0
elif (hue < 3.0):
red = 0.0
blue = midling
green = chroma
elif (hue < 4.0):
red = 0.0
green = midling
blue = chroma
elif (hue < 5.0):
red = midling
green = 0.0
blue = chroma
elif (hue < 6.0):
red = chroma
green = 0.0
blue = midling
# -------------------------------------------
# add min value to each
# -------------------------------------------
min_rgb = value - chroma
red = red + min_rgb
green = green + min_rgb
blue = blue + min_rgb
# -------------------------------------------
# round the numbers to useful values for gimp
# -------------------------------------------
red = round(red * 255)
green = round(green * 255)
blue = round(blue * 255)
# -------------------------------------------
# That should be it!
# -------------------------------------------
return(red, green, blue)
Feel free to test this. The input is an HSV tuple, where Hue is from 0 to 360, Saturation is from 0 to 100, and Value is from 0 to 100.
The notable difference comes here:
elif (hue < 3.0):
red = 0.0
blue = midling
green = chroma
Which suggests that the piecewise definition should have one piece changed, from
To
I have omitted the irrelevant pieces for brevity as this is already running long.
Please review and advise. Greysondn ( talk) 23:59, 10 November 2015 (UTC)
I don't think the style of the Disadvantages and Other cylindrical-coordinate color models is warranted on this site. Examples: "Such perversities led Cynthia Brewer, expert in color scheme choices for maps and information displays, to tell the American Statistical Association: ..." "The creators of HSL and HSV were far from the first to imagine colors fitting into conic or spherical shapes..."
I strongly recommend moving these sections towards a more neutral point of view. -- mafutrct ( talk) 11:28, 29 September 2015 (UTC)
There is an interesting discussion here about how and why HSL and HSV are used differently. http://stackoverflow.com/a/17350333/330663 Basically, HSV models how objects are lit (and thus is useful to photographers), whereas HSL is useful to painters who want to pick or "input" colors from a palette. Is this discussed in a reliable source somewhere? SharkD Talk 06:54, 18 November 2016 (UTC)
Given the breadth of the scope of this article, would it be okay to merge HCL color space here? SharkD Talk 03:01, 15 November 2016 (UTC)
I added the American English templates to the article and talk pages. There was a mix used with the vast majority being American. I changed "colour" to "color" except in book and journal titles. I suspect they need to be checked since the one article I checked that had "generalised" in the title was actually published as "Generalized". User-duck ( talk) 20:44, 3 September 2017 (UTC)
Both on the internet and in all software I've ever used, HSL has, in short, stood for 'Hue Sat Lum', not 'Hue Sat Lig', so why is it that in this article HSL is said to be an acronym for 'Hue, Saturation, Lightness' rather than 'Hue, Saturation, Luma' (or luminosity I'm not sure on which one it is)? BenYaMan ( talk) 15:40, 22 April 2018 (UTC)
I thought "luminance" should only be used for objects that emit light, not for objects which reflect light? SharkD Talk 17:46, 6 September 2017 (UTC)
In many of the descriptions of conversions, the modulus operator is applied to real values. This is confusing as the modulo operator is typically considered to only apply to integers, but the algorithms are only correct if mod is taken to produce a real-valued remainder. Even a programmer reading some of the algorithms might assume the integer interpretation of mod, especially since hue is often converted to a number between 0 and 6. Just before adding this comment, I had to delete an attempt to convey a "fixed" HSV->RGB conversion in incredibly broken English which also contained many factually incorrect statements. Presumably the author had attempted to implement the algorithm from Wikipedia before finding that it didn't produce the expected result. AnalyticalEngine ( talk) 03:51, 27 August 2018 (UTC)
I have split off the "Cylindrical-coordinate color models" section into Color_model#Cylindrical-coordinate_color_models. I think the "Disadvantages" section could also be split off into an article that deals with "perceptual uniformity"/"perceptual relevance" more generally. ➧ datumizer ☎ 00:50, 11 September 2018 (UTC)