# Conceptually Designing HSL Algorithm

This is a discussion on Conceptually Designing HSL Algorithm within the A Brief History of Cprogramming.com forums, part of the Community Boards category; edit: nvm...

1. ## Conceptually Designing HSL Algorithm

edit: nvm

2. The relationship between HSV and RGB is defined. If you implement it any other way, you are no longer dealing with HSV, but some weird "simpleid space." If you somehow come up with a mathematical expression that gives the same results in all cases, then good for you, but it's not going to be anywhere near as efficient as the typical method.

HSV is a defined concept, not an observed one, because it is based on human perception. We perceive the violet end of the spectrum to "wrap around" back onto the red end. But this is a psychological phenomenon, not a physical one. There is nothing in the universe that would indicate HSV as a "natural" way of representing color values. So if you diverge from what is defined, you are no longer working with HSV.

EDIT: In other words, HSV is NOT some ugly-looking approximation of some beautiful underlying concept. It IS the concept.

3. edit: nvm

4. Originally Posted by simpleid
i am in fact trying to redefine it.

that's the point. i specifically mentioned 'i simply don't like it', not 'it's not defined by the laws of nature' and i didn't say that i was going to define it as such, that i did only want a solution that 'felt more natural' despite the fact that it isn't
The HSV solution is completely elegant. The math appears unintuitive because it is the end result of a few very elegant looking diagrams. The Hue_to_RGB() function is just switching between a few linear functions depending on the actual value of hue.

i also didn't want to debate something trivial, just wanted to spark a discussion on finding a relationship between what does exist and something more potentially interesting.

i was just making an art of it. i thought some people might enjoy that.

but specifically i was asking help on an aspect of redefining it, so if you can contribute then do, please. otherwise making any arguments against my little venture will be futile so you might as well end it with that. :-P
Well, to address your questions on saturation, consider the variance in the differences from the mean of R, G, B, in other words, this value:

Code:
```double square(double x) { return x * x; }

double mean = (R + G + B) / 3.0;
double variance = square(R - mean) + square(G - mean) + square(B - mean);```
But that's not really good enough, because it assigns different values to (128, 64, 32) and (64, 32, 16) when these values obviously only differ in intensity, not saturation. There is an adjustment you can make to eliminate this difference, think about what it is.

Also, are your RGB values calibrated to the human eye, or are you using absolute intensities? Or are you using some form of gamma? This stuff all matters too.

5. Forgive me if I am wrong (I have only been looking at your sample image for about a minute now), but it seems like there is some flaw in your logic.

Now, according to my understanding of how you explained it, if we take that blue vertical line that you drew in the image, and we slide it horizontally to the right, we can take a sample of the RGB values at that corresponding "h" value. In other words, at some value "x" along the X-axis, the values of the 3 sine waves at that "x" position will be our RGB values.

The fundamental problem is the simple fact that under your example, you can never have "black" or "white" (RGB = 0 0 0 or RGB = 255 255 255), because there is never a moment in all of infinity when all 3 sine waves will all reach a trough or crest. So you cannot represent all colors.

That's my observation....but sorry if I am wrong. I am not well versed on the subject of HSL/HSV.

6. edit: nvm

7. Originally Posted by simpleid
i have done my research, and have found other implementations which encompass trig functions to come up with solutions. ;-)
Well yes, mapping an inherently polar space to a linear one is going to involve trig. That doesn't have anything to do with waves though.

i'm just working on my own, for an intellectual exercise. the point is, i want to *realize* a solution by *myself*. i already told you, you can't convince me to stop, so either aid in the discussion or ignore it. thanks!
I'm not convincing you to stop what you're doing. You asked for a discussion and you seem to want to exclude my opinion specifically. Okay...

i feel that if i can discover new ways to achieve the same effect, then i am doing something worth while. for that reason i prefer to keep doing these things, so that my software can be truly unique. :-)
I was trying to play along by bringing up a potential method for defining "saturation."

8. Color spaces and the math behind them are very well documented, defined, and proven. Anything else is reinventing the wheel.

9. edit: nvm

10. Okay, I give up. I have no idea what this thread is about. Are we supposed to bow down to your independent spirit or something? Anything actually on the topic of color spaces seems to get shot down.

11. don't be such an .............., my request for help was very clear

i couldn't think of a way to incorporate saturation in to the way i was
trying to figure this out.

you didn't have to say half of what you did, and i was only rightfully defending
the purpose of my post. which was meaningless for you to question.

the only thing that mattered was i was looking for some thoughts, just offering
thoughts on incorporating saturation would have been PLENTY.

and now for all of this you'll turn it on me to make me look like some kind of arrogant
ass when it was only my intent to justify.

i wish a mod would just lock this or delete it.

12. Originally Posted by simpleid
don't be such an .............., my request for help was very clear
No, you were droning on and on about how "artistic" you are, made some vague request for ideas, then stomped on everybody who decided to respond.

i couldn't think of a way to incorporate saturation in to the way i was
trying to figure this out.
Possibly because the entire idea is bogus. I tried to provide a fresh idea about saturation, you are still completely ignoring it, probably because you don't understand it.

you didn't have to say half of what you did, and i was only rightfully defending
the purpose of my post. which was meaningless for you to question.
You are a crackpot.

the only thing that mattered was i was looking for some thoughts, just offering
thoughts on incorporating saturation would have been PLENTY.
I did. You're too busy foaming at the mouth over the fact that somebody out there might be smarter than you, to notice it.

and now for all of this you'll turn it on me to make me look like some kind of arrogant ass when it was only my intent to justify.
First you say it's just an intellectual exercise, which requires no justification. Then you try to justify it. Make up your mind.

i wish a mod would just lock this or delete it.
I'm willing to discuss the original topic if you're willing to LISTEN.

13. I think this thread has derailed significantly.