POV-Ray : Newsgroups : povray.binaries.images : cubic interpolation for image_maps (2 jpegs - 63kb) Server Time
3 Aug 2024 00:25:43 EDT (-0400)
  cubic interpolation for image_maps (2 jpegs - 63kb) (Message 11 to 17 of 17)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 8 Mar 2007 12:46:54
Message: <45f04c0e$1@news.povray.org>
Tek wrote:
> "Samuel Benge" <stb### [at] hotmailcom> wrote in message 
> news:45eef8a7$1@news.povray.org...
>I figured I should post it anyway.
> 
> IMO the problem is it's only blending to the adjacent cell, and it always 
> uses pov's cubic curve rather than trying to maintain a smooth gradient.

Yes, I was hoping to control that with a poly_wave n statement after a 
cubic_mapped pigment_pattern, but it didn't work out very well. The 
cubic wave is still expressed in the same way, only shifted one way or 
another.

> If 
> I'm understanding correctly Vincent's technique was actually doing cubic 
> interpolation, rather than just using cubic_wave (which isn't equivalent)...
> 
> Of course I'm saying all this without checking anyone's source code, but 
> since it's based on my blended cells I would expect it to create curved 
> steps where there should be a smooth gradient, which would cause the problem 
> you're seeing.
> 
> Wow I explained that really badly!

Maybe so, but I understand why there are steps. I don't like it, but at 
least I have the newest version of MegaPOV now. It supports bi-cubic 
interpolation for image maps :)

~Sam


Post a reply to this message

From: Tek
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 8 Mar 2007 16:32:33
Message: <45f080f1$1@news.povray.org>
If you really wanted to do it with my system, which would not be a good 
idea, you'd need to overlap 4 copies of the pattern on every axis, so 16 for 
an image, with each component being adjusted to behave like a part in a 
cubic formula to create a nice curve through the surfaces.

My system just blends between 2 values, but to get a nice smooth slope you 
need to blend 4 using a much more complex formula.

-- 
Tek
http://evilsuperbrain.com


"Samuel Benge" <stb### [at] hotmailcom> wrote in message 
news:45f04c0e$1@news.povray.org...
> Tek wrote:
>> "Samuel Benge" <stb### [at] hotmailcom> wrote in message 
>> news:45eef8a7$1@news.povray.org...
>>I figured I should post it anyway.
>>
>> IMO the problem is it's only blending to the adjacent cell, and it always 
>> uses pov's cubic curve rather than trying to maintain a smooth gradient.
>
> Yes, I was hoping to control that with a poly_wave n statement after a 
> cubic_mapped pigment_pattern, but it didn't work out very well. The cubic 
> wave is still expressed in the same way, only shifted one way or another.
>
>> If I'm understanding correctly Vincent's technique was actually doing 
>> cubic interpolation, rather than just using cubic_wave (which isn't 
>> equivalent)...
>>
>> Of course I'm saying all this without checking anyone's source code, but 
>> since it's based on my blended cells I would expect it to create curved 
>> steps where there should be a smooth gradient, which would cause the 
>> problem you're seeing.
>>
>> Wow I explained that really badly!
>
> Maybe so, but I understand why there are steps. I don't like it, but at 
> least I have the newest version of MegaPOV now. It supports bi-cubic 
> interpolation for image maps :)
>
> ~Sam
>


Post a reply to this message

From: Bruno Cabasson
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 9 Mar 2007 09:00:00
Message: <web.45f1680c625f00b5f5fba6ef0@news.povray.org>
There is an interpolation method, based on signal-processing techniques,
known as 'Whittaker interpolation' that can be extended at 2 dimensions,
and therefore applies to 2-D data (diagrams, images or whatsoever that can
be expressed as f(u, v)). This method makes good interpolations and gives
good results.

The formula (seen in a book!) is:

Being given E(ui, vj), with i in [1..N], j in [1..M} the grid value of the
data in question, and with steps du in u and dv in v, the value of E in a
point (u, v) is given by:

        N    M
       ---- ----
                      sin(PI*(u-u1)/du - i*PI) sin(PI*(v-v1)/dv - j*PI)
E(u,v)=/    /   E(ui,vj)------------------------ ------------------------
       ---  ---           PI*(u-u1)/du - i*PI     PI*(v-v1)/dv - j*PI
         i=1  j=1

OK it is quite a complicated formula, and I apologize, but perhaps POV-team
members who have implemented math-related features in POV can understand
and give an opinion.

However, there must be somewhere well-known image-processing techniques to
perform interpolations. If some of you are fresh engineers ...


    Bruno


Post a reply to this message

From: Vincent Le Chevalier
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 9 Mar 2007 10:15:59
Message: <45f17a2f$1@news.povray.org>

> Being given E(ui, vj), with i in [1..N], j in [1..M} the grid value of the
> data in question, and with steps du in u and dv in v, the value of E in a
> point (u, v) is given by:
> 
>         N    M
>        ---- ----
>                       sin(PI*(u-u1)/du - i*PI) sin(PI*(v-v1)/dv - j*PI)
> E(u,v)=/    /   E(ui,vj)------------------------ ------------------------
>        ---  ---           PI*(u-u1)/du - i*PI     PI*(v-v1)/dv - j*PI
>          i=1  j=1
> 

Yes, I heard about this before. In fact, what this formula does is 
summing plenty of 2D sinc functions, one for each point of the grid. The 
scaling with PI is merely to ensure that each sinc is zero at all grid 
points, except the one it is centered on.

This interpolation is indeed good in signal processing, because if I 
remember correctly, it does not add frequencies higher than the sampling 
you already have from the grid.

But it seems prohibitive to compute, since you must consider every point 
of the grid each time you need a value. It can be sped up by considering 
a limited set of neighbours, but then it becomes tricky to ensure that 
the value and derivative(s) stay continuous.

-- 
Vincent


Post a reply to this message

From: Bruno Cabasson
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 9 Mar 2007 10:35:01
Message: <web.45f17d9d625f00b5f5fba6ef0@news.povray.org>
Vincent Le Chevalier <gal### [at] libertyALLsurfSPAMfr> wrote:

> > Being given E(ui, vj), with i in [1..N], j in [1..M} the grid value of the
> > data in question, and with steps du in u and dv in v, the value of E in a
> > point (u, v) is given by:
> >
> >         N    M
> >        ---- ----
> >                       sin(PI*(u-u1)/du - i*PI) sin(PI*(v-v1)/dv - j*PI)
> > E(u,v)=/    /   E(ui,vj)------------------------ ------------------------
> >        ---  ---           PI*(u-u1)/du - i*PI     PI*(v-v1)/dv - j*PI
> >          i=1  j=1
> >
>
> Yes, I heard about this before. In fact, what this formula does is
> summing plenty of 2D sinc functions, one for each point of the grid. The
> scaling with PI is merely to ensure that each sinc is zero at all grid
> points, except the one it is centered on.
>
> This interpolation is indeed good in signal processing, because if I
> remember correctly, it does not add frequencies higher than the sampling
> you already have from the grid.
>
> But it seems prohibitive to compute, since you must consider every point
> of the grid each time you need a value. It can be sped up by considering
> a limited set of neighbours, but then it becomes tricky to ensure that
> the value and derivative(s) stay continuous.
>
> --
> Vincent

You're right, it is not costless. But I have an application using it and it
works quite fast. You might use this interpolation only if you want quality
and/or if the extra computation time is neglectable wrt the rest of the
image. Many things are a compromise.

In addition, you should not retrict the neighbours otherwise you'll get
ondulations (you obviously studied signal processing :)).

    Bruno

PS: here's an interresting link:
http://www.cambridgeincolour.com/tutorials/image-interpolation.htm


Post a reply to this message

From: Vincent Le Chevalier
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 10 Mar 2007 18:15:14
Message: <45f33c02@news.povray.org>

> An easy-to-use macro of your technique would be useful, if it 
> renders/parses quickly. It is an improvement over linear
> interpolation, that much is evident.
> 

I posted a macro version of my technique under your thread with the same
subject in povray.binaries.scene-files. I wouldn't say it is quick...
But I don't really know if a quicker implementation can be done.

Of course since it is in Megapov now the incentive to optimize is a bit
diminished :-)

However, as I said in my message over at povray.binaries.scene-files, I
believe you could make interesting things by tweaking the computation a
bit. Since the bicubic method needs the slope at each grid point, you
could specify anything, not necessarily deducing it from the data as
I've done.

I also made a new comparison of the bilinear and bicubic methods using
this new scene file and a lower-res height field, see the attachment.

Regards,

-- 
Vincent


Post a reply to this message


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

Preview of image 'interpolations.jpg'
interpolations.jpg


 

From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 10 Mar 2007 19:44:04
Message: <45f350d4@news.povray.org>
Vincent Le Chevalier wrote:
> 
> I posted a macro version of my technique under your thread with the same
> subject in povray.binaries.scene-files. I wouldn't say it is quick...
> But I don't really know if a quicker implementation can be done.

Okay, I'll give it a look. There's always something to learn from 
techniques like this :)

> Of course since it is in Megapov now the incentive to optimize is a bit
> diminished :-)

Tell me about it!

> However, as I said in my message over at povray.binaries.scene-files, I
> believe you could make interesting things by tweaking the computation a
> bit. Since the bicubic method needs the slope at each grid point, you
> could specify anything, not necessarily deducing it from the data as
> I've done.
> 
> I also made a new comparison of the bilinear and bicubic methods using
> this new scene file and a lower-res height field, see the attachment.
> 
> Regards,

Looks good. Perfect, even.

~Sam


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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