POV-Ray : Newsgroups : povray.general : converting rgb to spectra Server Time
16 Oct 2026 09:57:34 EDT (-0400)
  converting rgb to spectra (Message 1 to 19 of 19)  
From: Remco Poelstra
Subject: converting rgb to spectra
Date: 21 Aug 2000 10:33:08
Message: <39A192D3.9659E6D5@home.nl>
Hi,

I saw in a message from Peter Popov in reply to Feature request for
pov3.5 (08/09/00 16:55), that rgb can be converted to spectra. That's
what I need., since I want to convert the rgb value to a corresponding
audio frequentie, and audio is spectra. Where can I find more
information on doing so? (I'm a newbie on complex math, so it should be
a little bit easy explained.)

Remco Poelstra


Post a reply to this message

From: Vahur Krouverk
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 11:51:21
Message: <39A15022.1157D2F4@aetec.ee>
Remco Poelstra wrote:
> 
> Hi,
> 
> I saw in a message from Peter Popov in reply to Feature request for
> pov3.5 (08/09/00 16:55), that rgb can be converted to spectra. That's
> what I need., since I want to convert the rgb value to a corresponding
> audio frequentie, and audio is spectra. Where can I find more
> information on doing so? (I'm a newbie on complex math, so it should be
> a little bit easy explained.)
> 
> Remco Poelstra

I don't think that you'll need complex math for this. In MegaPov source
code there is function (RGBtoHue in color.c)from MSGTracer, which
converts RGB to visible spectra (although part of it is commented out,
but You can get idea). Basically you should convert RGB to hue, then
convert hue to frequency (or wave length).


Post a reply to this message

From: Remco Poelstra
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 12:07:10
Message: <39A1A8DE.E97F9626@home.nl>
Vahur Krouverk wrote:
> 
> Remco Poelstra wrote:
> >
> > Hi,
> >
> > I saw in a message from Peter Popov in reply to Feature request for
> > pov3.5 (08/09/00 16:55), that rgb can be converted to spectra. That's
> > what I need., since I want to convert the rgb value to a corresponding
> > audio frequentie, and audio is spectra. Where can I find more
> > information on doing so? (I'm a newbie on complex math, so it should be
> > a little bit easy explained.)
> >
> > Remco Poelstra
> 
> I don't think that you'll need complex math for this. In MegaPov source
> code there is function (RGBtoHue in color.c)from MSGTracer, which
> converts RGB to visible spectra (although part of it is commented out,
> but You can get idea). Basically you should convert RGB to hue, then
> convert hue to frequency (or wave length).

All right, I'll, but what is hue exactly? I thought it's the 'rotation'
of the colorcircle.

Remco


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 12:40:42
Message: <chrishuff-3689A8.11420321082000@news.povray.org>
In article <39A192D3.9659E6D5@home.nl>, Remco Poelstra 
<rjp### [at] homenl> wrote:

> I saw in a message from Peter Popov in reply to Feature request for
> pov3.5 (08/09/00 16:55), that rgb can be converted to spectra. That's
> what I need., since I want to convert the rgb value to a corresponding
> audio frequentie, and audio is spectra. Where can I find more
> information on doing so? (I'm a newbie on complex math, so it should be
> a little bit easy explained.)

I think it would be very useful to have rgb2hls() and hls2rgb() 
functions, and similar ones for HSV and other color spaces. These could 
also be useful post_process filters. The only thing stopping me from 
writing them is a lack of knowledge of how to convert between them.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Ron Parker
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 12:45:04
Message: <slrn8q2ns2.13j.ron.parker@fwi.com>
On Mon, 21 Aug 2000 11:42:03 -0500, Chris Huff wrote:
>I think it would be very useful to have rgb2hls() and hls2rgb() 
>functions, and similar ones for HSV and other color spaces. These could 
>also be useful post_process filters. The only thing stopping me from 
>writing them is a lack of knowledge of how to convert between them.

The PostScript Language Reference Manual contains the necessary formulae,
and is available in PDF format from Adobe's website.  It also might
include some CMYK conversions, though I'm undecided as to the usefulness
of those.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 12:54:33
Message: <chrishuff-EC51D2.11555421082000@news.povray.org>
In article <slr### [at] fwicom>, ron### [at] povrayorg 
wrote:

> The PostScript Language Reference Manual contains the necessary formulae,
> and is available in PDF format from Adobe's website.  It also might
> include some CMYK conversions, though I'm undecided as to the usefulness
> of those.

Thanks for the information! I will check it out...
I tend to agree about the CMYK, it is just too dependant on output 
devices. However, a simple conversion might still be useful, if the 
documentation warns about the fact it isn't very accurate. The problem 
is, where do we put the K? The other color spaces could be stored in the 
same rgb vectors, the components would just have different meanings. 
Maybe the function should optionally take a float vector which it would 
store the K value in.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: David Fontaine
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 18:15:50
Message: <39A1A7FA.53ED54C8@faricy.net>
Chris Huff wrote:

> I think it would be very useful to have rgb2hls() and hls2rgb()
> functions, and similar ones for HSV and other color spaces. These could
> also be useful post_process filters. The only thing stopping me from
> writing them is a lack of knowledge of how to convert between them.

I wrote a macro to do RGB<->HLS...

--
David Fontaine   <dav### [at] faricynet>   ICQ 55354965
Please visit my website:  http://davidf.faricy.net/


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 18:43:33
Message: <chrishuff-76DC9C.17445421082000@news.povray.org>
In article <39A1A7FA.53ED54C8@faricy.net>, David Fontaine 
<dav### [at] faricynet> wrote:

> I wrote a macro to do RGB<->HLS...

And I have it on my system. :-)
I just haven't reverse engineered it and written a POV conversion 
function yet. And it only takes care of one color space.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Halbert
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 21:33:00
Message: <39a1d84c@news.povray.org>
Psuedocode plagerized from Computer Graphics and Principals 2nd Edition:

procedure RGB_To_HSV( r, g b: real; var h,s v : real)
begin
    max := Maximum(r,g,b);
    min := Minimum(r,g,b);

    v := max;
if max <> 0 then
    s := (max - min)/max;
else s := 0;
if s = 0 then
   h := UNDEFINED
else
    begin
        delta := max - min;
        if r = max then
            h := (g - b)/delta;
        else if g = max then
            h := 2 + (b - r)/delta;
        else if b = max then
            h := 4 + (r - g)/delta;
        h := h* 60;
        if h < 0 then
            h := h + 360;
    end
end


This should be easily converted into a macro (assumming I haven't made too
many typing errors.)

"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On Mon, 21 Aug 2000 11:42:03 -0500, Chris Huff wrote:
> >I think it would be very useful to have rgb2hls() and hls2rgb()
> >functions, and similar ones for HSV and other color spaces. These could
> >also be useful post_process filters. The only thing stopping me from
> >writing them is a lack of knowledge of how to convert between them.
>
> The PostScript Language Reference Manual contains the necessary formulae,
> and is available in PDF format from Adobe's website.  It also might
> include some CMYK conversions, though I'm undecided as to the usefulness
> of those.
>
> --
> Ron Parker   http://www2.fwi.com/~parkerr/traces.html
> My opinions.  Mine.  Not anyone else's.
>


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 23:05:08
Message: <chrishuff-87615D.22063021082000@news.povray.org>
In article <39a1d84c@news.povray.org>, "Halbert" <hha### [at] capitalnet> 
wrote:

> Psuedocode plagerized from Computer Graphics and Principals 2nd Edition:
...snip...
> This should be easily converted into a macro (assumming I haven't 
> made too many typing errors.)

Whee, Pascal...the last time I read Pascal I was trying to convert a 
demo program written in it to C. It was surprisingly easy, actually...
Here is an untested attempt at a straight conversion to POV:

#macro RGB2HSV(RGB)
    #local Max = max(RGB.r, max(RGB.g, RGB.b));
    #local Min = min(RGB.r, min(RGB.g, RGB.b));

    #local V = Max;

    #if(Max != 0)
        #local S = (Max - Min)/Max;
    #else
        #local S = 0;
    #end

    #if(S = 0)
        #local H = 0;
    #else
        #local Delta = Max - Min;
        #if(RGB.r = Max)
            #local H = (RGB.g - RGB.b)/Delta;
        #else
            #if(RGB.g = Max)
                #local H = 2 + (RGB.b - RGB.r)/Delta;
            #else
                #if(RGB.b = Max)
                    #local H = 4 + (RGB.r - RGB.g)/Delta;
                #end
            #end
        #end

        #local H = H*60;
        #if(H < 0)
            #local H = H + 360;
        #end
    #end
    (< H, S, V>)
#end

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: David Fontaine
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 23:36:05
Message: <39A1F30B.4FA04AB6@faricy.net>
Chris Huff wrote:

> In article <39A1A7FA.53ED54C8@faricy.net>, David Fontaine
> <dav### [at] faricynet> wrote:
>
> > I wrote a macro to do RGB<->HLS...
>
> And I have it on my system. :-)
> I just haven't reverse engineered it and written a POV conversion
> function yet. And it only takes care of one color space.

I know... The only others I know of are CMYK and spectra, what is HSV?

--
David Fontaine   <dav### [at] faricynet>   ICQ 55354965
Please visit my website:  http://davidf.faricy.net/


Post a reply to this message

From: Ken
Subject: Re: converting rgb to spectra
Date: 21 Aug 2000 23:41:45
Message: <39A1F5F5.571B77B8@pacbell.net>
David Fontaine wrote:

> I know... The only others I know of are CMYK and spectra, what is HSV?

http://www.inforamp.net/~poynton/Poynton-colour.html

-- 
Ken Tyler - 1400+ POV-Ray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Vahur Krouverk
Subject: Re: converting rgb to spectra
Date: 22 Aug 2000 02:47:00
Message: <39A2221F.B8F2E0D2@aetec.ee>
Chris Huff wrote:
> 
> In article <39A1A7FA.53ED54C8@faricy.net>, David Fontaine
> <dav### [at] faricynet> wrote:
> 
> > I wrote a macro to do RGB<->HLS...
> 
> And I have it on my system. :-)
> I just haven't reverse engineered it and written a POV conversion
> function yet. And it only takes care of one color space.
> 
> --
> Christopher James Huff

I've written conversion between RGB and HSV, HSL XYZ, xyY, YIQ color
spaces as C function in colour.c. (I've not tested it very much, hope I
haven't made too much mistakes in entering marrix constants). If someone
wants to add coversion support for POV-Ray language, then I can send
source code.


Post a reply to this message

From: David Fontaine
Subject: Re: converting rgb to spectra
Date: 22 Aug 2000 17:11:21
Message: <39A2EA59.F81B8ADC@faricy.net>
Ken wrote:

> David Fontaine wrote:
>
> > I know... The only others I know of are CMYK and spectra, what is HSV?
>
> http://www.inforamp.net/~poynton/Poynton-colour.html
>
> --
> Ken Tyler - 1400+ POV-Ray, Graphics, 3D Rendering, and Raytracing Links:
> http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/

Man, a person could spend their entire life studying color! I looked in my
encyclopedia too and found several pages on the Purkinje shift and
Bezold-Brucke effect, simultaneous and successive chromatic adaption,
tristimulus, etc, even the human brain's adjustments in percieved color and
color psychology...

--
David Fontaine   <dav### [at] faricynet>   ICQ 55354965
Please visit my website:  http://davidf.faricy.net/


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 22 Aug 2000 17:54:47
Message: <chrishuff-8AC48D.16561022082000@news.povray.org>
In article <39A2221F.B8F2E0D2@aetec.ee>, Vahur Krouverk 
<vah### [at] aetecee> wrote:

> I've written conversion between RGB and HSV, HSL XYZ, xyY, YIQ color
> spaces as C function in colour.c. (I've not tested it very much, hope I
> haven't made too much mistakes in entering marrix constants). If someone
> wants to add coversion support for POV-Ray language, then I can send
> source code.

Sounds interesting...could you post the conversion functions to 
povray.programming or povray.binaries.programming?

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Chuck Roberts
Subject: Re: converting rgb to spectra
Date: 24 Aug 2000 08:52:27
Message: <39A51B52.30D1A6E0@accn.org>
Go to my raytracing page at:
http://www.crosswinds.net/~robertsc/raytrac2.htm . I have a link
for converting from RGB to spectra there.

Remco Poelstra wrote:
> 
> Hi,
> 
> I saw in a message from Peter Popov in reply to Feature request for
> pov3.5 (08/09/00 16:55), that rgb can be converted to spectra. That's
> what I need., since I want to convert the rgb value to a corresponding
> audio frequentie, and audio is spectra. Where can I find more
> information on doing so? (I'm a newbie on complex math, so it should be
> a little bit easy explained.)
> 
> Remco Poelstra

-- 
See my Free stuff page. It compares free website providers, and
lists free internet access providers.
http://www.crosswinds.net/~robertsc/free.htm

Win98 help file loaded with hints and tips, including securing a
Win 95/98 PC in a classroom setting. VB4 help file with lots of
code and hints. 
At http://www.crosswinds.net/~robertsc/


Post a reply to this message

From: Vahur Krouverk
Subject: Re: converting rgb to spectra
Date: 25 Aug 2000 03:32:01
Message: <39A62132.B898A45A@aetec.ee>
Chris Huff wrote:
> 
> In article <39A2221F.B8F2E0D2@aetec.ee>, Vahur Krouverk
> <vah### [at] aetecee> wrote:
> 
> > I've written conversion between RGB and HSV, HSL XYZ, xyY, YIQ color
> > spaces as C function in colour.c. (I've not tested it very much, hope I
> > haven't made too much mistakes in entering marrix constants). If someone
> > wants to add coversion support for POV-Ray language, then I can send
> > source code.
> 
> Sounds interesting...could you post the conversion functions to
> povray.programming or povray.binaries.programming?
> 
Ok, I'll do it after I complete this message.
povray.binaries.programming will be the group. I've made tests for
ensuring their correctness and I believe, that HSV, HSL and YIQ
conversions are correct (at least BMRT gave same output). Hopefully XYZ
and xyY are correct too, as they involve only matrix multiplication.


Post a reply to this message

From: Chris Huff
Subject: Re: converting rgb to spectra
Date: 30 Aug 2000 17:17:30
Message: <chrishuff-AB461B.16190530082000@news.povray.org>
In article <39A62132.B898A45A@aetec.ee>, Vahur Krouverk 
<vah### [at] aetecee> wrote:

> Ok, I'll do it after I complete this message.
> povray.binaries.programming will be the group. I've made tests for
> ensuring their correctness and I believe, that HSV, HSL and YIQ
> conversions are correct (at least BMRT gave same output). Hopefully XYZ
> and xyY are correct too, as they involve only matrix multiplication.

I downloaded it and will take a look at these. It would also help if you 
had a link to pages explaining what they *are*, but I can probably find 
that somewhere myself...do the XYZ and xyZ ones use a color matrix 
similar to my post_process filter?

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Markus Becker
Subject: Re: converting rgb to spectra
Date: 12 Sep 2000 09:47:23
Message: <39BE3588.F36F3A9A@student.uni-siegen.de>
Remco Poelstra wrote:
> 
> All right, I'll, but what is hue exactly? I thought it's the 'rotation'
> of the colorcircle.

You're right. And as the rotation (or angle) in the colorcircle it
corresponds directly to frequency.

Markus


Post a reply to this message

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