POV-Ray : Newsgroups : povray.general : converting rgb to spectra Server Time
9 Aug 2024 15:24:58 EDT (-0400)
  converting rgb to spectra (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
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

Goto Latest 10 Messages Next 9 Messages >>>

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