POV-Ray : Newsgroups : povray.advanced-users : rgb vs srgb Server Time
23 Dec 2024 02:56:52 EST (-0500)
  rgb vs srgb (Message 1 to 10 of 48)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Thomas de Groot
Subject: rgb vs srgb
Date: 9 Sep 2011 10:27:50
Message: <4e6a2266$1@news.povray.org>
Is it possible one way or another, to determine/calculate the srgb 
equivalent of a given rgb vector? and vice-versa of course?

Thomas


Post a reply to this message

From: Warp
Subject: Re: rgb vs srgb
Date: 9 Sep 2011 10:56:59
Message: <4e6a293b@news.povray.org>
Thomas de Groot <tenDOTlnDOTretniATtoorgedDOTt> wrote:
> Is it possible one way or another, to determine/calculate the srgb 
> equivalent of a given rgb vector? and vice-versa of course?

  Try the method described here: http://en.wikipedia.org/wiki/SRGB

-- 
                                                          - Warp


Post a reply to this message

From: Ive
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 02:49:44
Message: <4e6b0888$1@news.povray.org>
Am 09.09.2011 16:27, schrieb Thomas de Groot:
> Is it possible one way or another, to determine/calculate the srgb
> equivalent of a given rgb vector? and vice-versa of course?
>

This is surely possible but the way it is done depends on what you
actually mean by 'rgb'.
Assuming you mean the rgb color space that is using the same primaries 
as sRGB but is in linear space (i.e scRGB) all you need is a gamma 
transformation like:

#declare sRGB_Gamma = function(C) {
   select(C-0.0031308, C*12.92 : 1.055*pow(C,1/2.4)-0.055)
}

and the inverse for sRGB -> scRGB:

#declare sRGB_GammaInverse = function(C) {
   select(C-0.04045, C/12.92, pow((C+0.055)/1.055,2.4))
}

Assuming both input and output within 0.0 - 1.0 range.

Now just write macros that do handle the 3 color channels with these 
functions but keep filter and transmit values untouched.

Otherwise (when you are not referring to scRGB) you'll need to transform 
it via CIE xyz color space where my CIE.inc file should come in handy.

-Ive


P.S. untested code as I do not have POV-Ray available atm.


Post a reply to this message

From: Thomas de Groot
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 03:51:32
Message: <4e6b1704$1@news.povray.org>
Thank you Warp and Ive. Let me try to be a bit more explicit. It boils 
down to the need of having a real srgb color picker, as was already 
discussed/wished in these ng's some time ago. All color pickers (like 
Sven's for instance) that I know of use (linear) rgb as far as I am aware.

As a user of Poser and Poseray, I often like to tone the skin of the 
human figures. The latest Poseray version does this nicely with some 
added macros where you just have to put in the tone's srgb values. 
However, that is where my problem arises: I can define those tones in my 
ancient PSP or in the latest Gimp, but those give the values in linear 
space. So, to get the result I want I have to correct the Poseray output 
just by changing 'srgb' into 'rgb' where necessary. If not, the result 
is way to dark in general. This works but is a bit fastidious. Better 
would be to have the 'real' srgb values of the tones from start. I hope 
I made myself clear...

Thomas


Post a reply to this message

From: Ive
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 05:06:33
Message: <4e6b2899@news.povray.org>
Am 10.09.2011 09:50, schrieb Thomas de Groot:
> All color pickers (like
> Sven's for instance) that I know of use (linear) rgb as far as I am aware.

While I'm not aware of any that *does* use *linear* rgb values (don't 
know about "Sven's" though).

> As a user of Poser and Poseray, I often like to tone the skin of the
> human figures. The latest Poseray version does this nicely with some
> added macros where you just have to put in the tone's srgb values.
> However, that is where my problem arises:
> I can define those tones in my
> ancient PSP or in the latest Gimp, but those give the values in linear
> space.

I really doubt that.

> So, to get the result I want I have to correct the Poseray output
> just by changing 'srgb' into 'rgb' where necessary. If not, the result
> is way to dark in general. This works but is a bit fastidious. Better
> would be to have the 'real' srgb values of the tones from start.

Sorry, but I've got the feeling that there is some fundamental 
misconception on your side. sRGB is by definition gamma corrected 
(composed of two functions as shown in my last post) and the linear 
variant of it is called scRGB and this *linear* rgb space should be used 
for *any* kind of math applied to colors (that is why POV-Ray 
internally always assumes linear rgb values). But I don't know what 
FlyerX actually does as I'm just using PoseRay's geometry output in 
combination with my own textures.
Actually I'm not using PoseRay anymore as it does not work on my machine 
(x64 with AMD OpenGL drivers) but this is a different story...


> I hope I made myself clear...

...nope :(

-Ive


Post a reply to this message

From: Thomas de Groot
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 07:21:08
Message: <4e6b4824@news.povray.org>
On 10-9-2011 11:06, Ive wrote:
> Am 10.09.2011 09:50, schrieb Thomas de Groot:
>> All color pickers (like
>> Sven's for instance) that I know of use (linear) rgb as far as I am
>> aware.
>
> While I'm not aware of any that *does* use *linear* rgb values (don't
> know about "Sven's" though).

Right. I see I have got it all wrong obviously... ;-) What I mean is 
simply the use of rgb (as in POV-Ray) versus srgb (as in POV-Ray too).

>
>> As a user of Poser and Poseray, I often like to tone the skin of the
>> human figures. The latest Poseray version does this nicely with some
>> added macros where you just have to put in the tone's srgb values.
>> However, that is where my problem arises:
>> I can define those tones in my
>> ancient PSP or in the latest Gimp, but those give the values in linear
>> space.
>
> I really doubt that.

I am sure you do :-)

>
>> So, to get the result I want I have to correct the Poseray output
>> just by changing 'srgb' into 'rgb' where necessary. If not, the result
>> is way to dark in general. This works but is a bit fastidious. Better
>> would be to have the 'real' srgb values of the tones from start.
>
> Sorry, but I've got the feeling that there is some fundamental
> misconception on your side. sRGB is by definition gamma corrected
> (composed of two functions as shown in my last post) and the linear
> variant of it is called scRGB and this *linear* rgb space should be used
> for *any* kind of math applied to colors (that is why POV-Ray internally
> always assumes linear rgb values). But I don't know what FlyerX actually
> does as I'm just using PoseRay's geometry output in combination with my
> own textures.

What I see in POV-Ray is that, e.g. rgb <213,127,79> does not render 
identical to srgb <213,127,79>. I would like to know what srgb values 
correspond to the given rgb ones. This is independent, I assume, of what 
Poseray does...

>> I hope I made myself clear...
>
> ...nope :(

<sigh> I was not surprised...

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 08:12:44
Message: <4e6b543c$1@news.povray.org>
On 10-9-2011 13:20, Thomas de Groot wrote:

> What I see in POV-Ray is that, e.g. rgb <213,127,79> does not render
> identical to srgb <213,127,79>. I would like to know what srgb values
> correspond to the given rgb ones. This is independent, I assume, of what
> Poseray does...
>
obviously: rgb <213,127,79>/255 and srgb <213,127,79>/255

Thomas


Post a reply to this message

From: Ive
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 08:23:48
Message: <4e6b56d4@news.povray.org>
Am 10.09.2011 13:20, schrieb Thomas de Groot:

> What I see in POV-Ray is that, e.g. rgb <213,127,79> does not render
> identical to srgb <213,127,79>.

Well, assuming you are *not* talking about HDR values but actually mean
"<213,127,79> / 255" what is wrong with using the functions given within 
my very first reply?

#macro scRGB_to_sRGB(Color)
    rgb <sRGB_Gamma(Color.red),
	sRGB_Gamma(Color.green),
	sRGB_Gamma(Color.blue)>
#end

if you need the inverse transformation or actually want to input values 
in 8bit (0..255) range I'll leave it up to you to write these macro as 
an exercise ;)

But what I do not get is why you do not simply type srgb <whatever 
values> when you are actually using sRGB values (e.g. from a color 
picker) and rgb <whatever values> when using linear values.

-Ive


Post a reply to this message

From: Thomas de Groot
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 10:48:04
Message: <4e6b78a4$1@news.povray.org>
On 10-9-2011 14:23, Ive wrote:
> Well, assuming you are *not* talking about HDR values but actually mean
> "<213,127,79> / 255" what is wrong with using the functions given within
> my very first reply?
>
> #macro scRGB_to_sRGB(Color)
> rgb <sRGB_Gamma(Color.red),
> sRGB_Gamma(Color.green),
> sRGB_Gamma(Color.blue)>
> #end

No HDR! I shall try this indeed.

>
> if you need the inverse transformation or actually want to input values
> in 8bit (0..255) range I'll leave it up to you to write these macro as
> an exercise ;)

<grin> I am not really good at this. I am even awfully moronic to tell 
the truth ;-)

>
> But what I do not get is why you do not simply type srgb <whatever
> values> when you are actually using sRGB values (e.g. from a color
> picker) and rgb <whatever values> when using linear values.

Well mainly because color pickers give values as rgb. If I want to use 
that same shade as srgb, for example in Poseray, I do not know what the 
corresponding values are. However, your functions may help me with that 
indeed! Thanks!!

Thomas


Post a reply to this message

From: Alain
Subject: Re: rgb vs srgb
Date: 10 Sep 2011 12:58:47
Message: <4e6b9747@news.povray.org>

> On 10-9-2011 14:23, Ive wrote:
>> Well, assuming you are *not* talking about HDR values but actually mean
>> "<213,127,79> / 255" what is wrong with using the functions given within
>> my very first reply?
>>
>> #macro scRGB_to_sRGB(Color)
>> rgb <sRGB_Gamma(Color.red),
>> sRGB_Gamma(Color.green),
>> sRGB_Gamma(Color.blue)>
>> #end
>
> No HDR! I shall try this indeed.
>
>>
>> if you need the inverse transformation or actually want to input values
>> in 8bit (0..255) range I'll leave it up to you to write these macro as
>> an exercise ;)
>
> <grin> I am not really good at this. I am even awfully moronic to tell
> the truth ;-)
>
>>
>> But what I do not get is why you do not simply type srgb <whatever
>> values> when you are actually using sRGB values (e.g. from a color
>> picker) and rgb <whatever values> when using linear values.
>
> Well mainly because color pickers give values as rgb. If I want to use
> that same shade as srgb, for example in Poseray, I do not know what the
> corresponding values are. However, your functions may help me with that
> indeed! Thanks!!
>
> Thomas

Almost all colour pickers, like the ones in Gimp or Paint, work in sRGB 
space. They assume a source encoded in sRGB space and return a value 
that is assumed to be used in the sRGB space.
Just try picking colour for 25%, 50% and 75% grays and see the actual 
results...



Alain


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.