POV-Ray : Newsgroups : povray.binaries.images : texture interpolation... why rgb ? Server Time
2 Aug 2024 10:21:25 EDT (-0400)
  texture interpolation... why rgb ? (Message 6 to 15 of 25)  
<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: scott
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 09:10:53
Message: <474ec86d$1@news.povray.org>
> There is no point in trying YUV/YIQ/Secam/Pal/NTSC... colorspace as
> they are matrix transformation of RGB, and as such keep the same result.

Yuv certainly isn't a simple matrix transform, which is why I mentioned it 
earlier.

FYI to convert from RGB to Yuv do the following (via XYZ):

XYZ = [some_matrix] * RGB
(the matrix depends on which colour space your RGB is in, choose sRGB, PAL, 
NTSC whatever)

x = X/(X+Y+Z)
y = Y/(Y+Y+Z)

u = 2*x/(6*y-1.5*x)
v = 4.5*y/(6*y-1.5*x)

Y will give you the "brightness" and uv will give you the colour. 
Interpolating uv linearly will give the smoothest change in colour, as each 
distance in your "picture" will correspond to an equal change in "colour" as 
the eye sees it.


Post a reply to this message

From: scott
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 11:14:44
Message: <474ee574$1@news.povray.org>
Oh I knocked up a quick program to interpolate between two colours in RGB 
space and Yuv space.  In each pair, the top version is RGB, the lower 
version is Yuv.

Actually, I just realised, you were probably thinking of the YUV signals 
used in TV, that are just linear combinations of RGB.  I'm talking about the 
CIE Yuv color space, revised in 1976 so that colours are spread equally in 
the uv plane.  See:

http://hyperphysics.phy-astr.gsu.edu/hbase/vision/cie1976.html


Post a reply to this message


Attachments:
Download 'interpolation comparison.png' (3 KB)

Preview of image 'interpolation comparison.png'
interpolation comparison.png


 

From: Le Forgeron
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 13:04:48
Message: <474eff40$1@news.povray.org>
Le 29.11.2007 17:14, scott nous fit lire :

> Actually, I just realised, you were probably thinking of the YUV signals
> used in TV, that are just linear combinations of RGB. 
Yes, right.

> I'm talking about
> the CIE Yuv color space, revised in 1976 so that colours are spread
> equally in the uv plane.  See:

I give up on the evaluation of the spectrum... as for all CIELab,
L*a*b* and such... it's far too much complex and removed from my
skill with computer.
Converting formulaes which request the performance of integration is
a bit too much.


-- 
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius


Post a reply to this message

From: Trevor G Quayle
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 15:30:01
Message: <web.474f21112088bdecc150d4c10@news.povray.org>
Le Forgeron <jgr### [at] freefr> wrote:
> I had a try with RGB (the pov current way), HSL & HSV. (see attached
> picture)
>

I've been having a look at this.  One problem in your graphic is the
interpolation of opposite colours in HSV and HSL.
You are basically interpolating linearly between individual H,S and V/L values.
The interpolation of H is done in the shortest direction around the
circumference. This poses a problem because there is no logical way to choose
the direction to interpolate H around the circumference, as both directions are
equal in length, so you have chosen to interpolate directly across the colour
space, which creates a discontinuity (eg: check the interpolation of
<1,0,0><0,1,1> compared to <1,0,0><0.001,1,1>, they should be virtually
indistinguishable, but the slight value added to the R value tips the shortest
route from being undefined to defined).  It would be far better to interploate
all colours directly across the colour space to remove this discontinuity.

A second problem I see is that this really only shows the halfway colour, and
not the full transition from one to the other.

The attached image shows interpolation between pure red and the other 5 pure
colours using interpolation across the colour space as described above.

top band: HSV
middle band: RGB
bottom band: HSL

Looking at this, RGB interpolation seems to give the most pleasing transition to
the eye (my eye at least).

-tgq


Post a reply to this message


Attachments:
Download 'interp.jpg' (72 KB)

Preview of image 'interp.jpg'
interp.jpg


 

From: Le Forgeron
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 15:52:44
Message: <474f269c$1@news.povray.org>
Le 29.11.2007 21:29, Trevor G Quayle nous fit lire :
> Le Forgeron <jgr### [at] freefr> wrote:
>> I had a try with RGB (the pov current way), HSL & HSV. (see attached
>> picture)
>>
> 
> I've been having a look at this.  One problem in your graphic is the
> interpolation of opposite colours in HSV and HSL.
> You are basically interpolating linearly between individual H,S and V/L values.
> The interpolation of H is done in the shortest direction around the
> circumference. This poses a problem because there is no logical way to choose
> the direction to interpolate H around the circumference, as both directions are
> equal in length, so you have chosen to interpolate directly across the colour
> space, which creates a discontinuity (eg: check the interpolation of
> <1,0,0><0,1,1> compared to <1,0,0><0.001,1,1>, they should be virtually
> indistinguishable, but the slight value added to the R value tips the shortest
> route from being undefined to defined).  It would be far better to interploate
> all colours directly across the colour space to remove this discontinuity.

Did you look at my code in p.b.sf ?
H was not linearly interpolated. There is a bit of vectors involved.
RGB or HSV/L: red & cyan mix as a shade of grey. (null saturation)
If one is shorter than, it is defined...
Now, should the path be alike is another problem: at any moment you
will have to choose between the upper path and the lower path...
There is two ways for opposites on a circle. And no good choice.



> 
> A second problem I see is that this really only shows the halfway colour, and
> not the full transition from one to the other.

I did as I could in SDL. Patching lighting.cpp around line 5251 is
an idea I'm not yet ready to perform for a continuous gradation. Not
tonight anyway.
May be next week... but I want more control than changing it from
RGB to HSL/HSV hardcoded.
So reflexion is needed before trying that.

A problem with your picture: it only uses saturated colors. What
about lighter, darker, white & black ?
Mixing a lighter blue & darker blue ? Not a saturated blue in RGB model.

-- 
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius


Post a reply to this message

From: Trevor G Quayle
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 16:30:01
Message: <web.474f2e6c2088bdecc150d4c10@news.povray.org>
Le Forgeron <jgr### [at] freefr> wrote:
> Did you look at my code in p.b.sf ?
> H was not linearly interpolated. There is a bit of vectors involved.
> RGB or HSV/L: red & cyan mix as a shade of grey. (null saturation)
> If one is shorter than, it is defined...
> Now, should the path be alike is another problem: at any moment you
> will have to choose between the upper path and the lower path...
> There is two ways for opposites on a circle. And no good choice.

Actually I didn't look at the actual code, I was commenting more on the
appearance of the graphic.  The main problem that stood out to me was that 2
pure colours interpolated as a pure colour (red to blue = magenta) which
indicated to me that the path was interpolating between the H values, following
the perimeter of the colour space, rather than cutting directly across which
gives a different shade, whereas the opposite colours are interpolated directly
across.

>
>
>
> >
> > A second problem I see is that this really only shows the halfway colour, and
> > not the full transition from one to the other.
>
> I did as I could in SDL. Patching lighting.cpp around line 5251 is
> an idea I'm not yet ready to perform for a continuous gradation. Not
> tonight anyway.
> May be next week... but I want more control than changing it from
> RGB to HSL/HSV hardcoded.
> So reflexion is needed before trying that.
>

I can understand the problem in getting this to work.  It took me a while to
write the SDL code to get smooth transitions.


> A problem with your picture: it only uses saturated colors. What
> about lighter, darker, white & black ?
> Mixing a lighter blue & darker blue ? Not a saturated blue in RGB model.

Here's some new mixes using different shades of red:

Top to bottom:
1. red to dark red
2. red to light red
3. dark red to light red
4. red to black
5. red to white

If there's any particular mix you want I can make an image for you, or I could
post the code.  The difficult trick in the interpolation is that you have to
convert the RGB to HSV/HSL(polar) to XYZ(cartesian) coordinates, interpolate
then convert back XYZ -> HSV/HSL -> RGB.

-tgq


Post a reply to this message


Attachments:
Download 'interp2.jpg' (58 KB)

Preview of image 'interp2.jpg'
interp2.jpg


 

From: Trevor G Quayle
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 16:40:01
Message: <web.474f30f62088bdecc150d4c10@news.povray.org>
Here's a better version of the original one without gamma f***ing it up.  (I
have to stop using PNG, it causes nothing but gamma problems for me).  You can
still see the big differences, particularly between red and green or blue.

The HSL doesn't look to bad here, but I still prefer the RGB (HSV is completely
out...)

-tgq


Post a reply to this message


Attachments:
Download 'interp3.jpg' (68 KB)

Preview of image 'interp3.jpg'
interp3.jpg


 

From: Trevor G Quayle
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 16:50:00
Message: <web.474f33422088bdecc150d4c10@news.povray.org>
"Trevor G Quayle" <Tin### [at] hotmailcom> wrote:
> Here's a better version of the original one without gamma f***ing it up.  (I
> have to stop using PNG, it causes nothing but gamma problems for me).  You can
> still see the big differences, particularly between red and green or blue.
>
> The HSL doesn't look to bad here, but I still prefer the RGB (HSV is completely
> out...)
>
> -tgq

Here's an intersting take on this one.  The transitions are converted to
equal-weighting grayscale (r=g=b=0.333).

Of particular note is the transition from red to blue or green, where the gray
value increases then decreases for both the HSV and HSL, however not as
drastically for the HSL.

-tgq


Post a reply to this message


Attachments:
Download 'interp4.jpg' (52 KB)

Preview of image 'interp4.jpg'
interp4.jpg


 

From: Trevor G Quayle
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 17:10:01
Message: <web.474f37b32088bdecc150d4c10@news.povray.org>
One more interesting little experiment before I pack it in for the day.

Here I interpolated between pure Blue and Red, Green, and Gray with an
equivilant intesity (0.11).  The top shows it in colour and the bottom shows it
converted to grayscale via an external converter.

Here it can be clearly seen that the RGB interpolation retains constant
intensity, whereas the other two do not.

-tgq


Post a reply to this message


Attachments:
Download 'interp5.jpg' (58 KB)

Preview of image 'interp5.jpg'
interp5.jpg


 

From: Warp
Subject: Re: texture interpolation... why rgb ?
Date: 29 Nov 2007 17:42:54
Message: <474f406e$1@news.povray.org>
scott wrote:
> Oh I knocked up a quick program to interpolate between two colours in
> RGB space and Yuv space.  In each pair, the top version is RGB, the
> lower version is Yuv.

  The yuv interpolation doesn't look half-bad.


Post a reply to this message

<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>

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