POV-Ray : Newsgroups : povray.binaries.images : cubic interpolation for image_maps (2 jpegs - 63kb) Server Time
4 Nov 2024 20:12:03 EST (-0500)
  cubic interpolation for image_maps (2 jpegs - 63kb) (Message 1 to 10 of 17)  
Goto Latest 10 Messages Next 7 Messages >>>
From: Samuel Benge
Subject: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 6 Mar 2007 21:10:26
Message: <45ee1f12@news.povray.org>
Hello everyone. I think there was a patch for this somewhere once... but 
anyway.

Based on Tek's (very clever) blended cells pattern, I have made a small 
macro which provides cubic interpolation between an image_map's pixels.

It's easy to use, as long as you can provide the exact width and height 
for the input image. You can specify the amount of blurring to perform. 
It could be useful for light probes, height_fields, or anything else you 
could think of. The files are available now at p.b.scene-files. A basic 
example file is included.

Hope it's useful to someone :)

~Sam


Post a reply to this message


Attachments:
Download 'cubic_image_map2.jpg' (35 KB) Download 'cubic_image_map1.jpg' (27 KB)

Preview of image 'cubic_image_map2.jpg'
cubic_image_map2.jpg

Preview of image 'cubic_image_map1.jpg'
cubic_image_map1.jpg


 

From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 6 Mar 2007 21:13:01
Message: <45ee1fad@news.povray.org>
Oh, I should have mentioned that the first example in each of the 
attached images uses the macro. The rest are already available in the 
current version of POV.

~Sam


Post a reply to this message

From: Vincent Le Chevalier
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 05:05:28
Message: <45ee8e68@news.povray.org>
Funny, I did something similar a while ago, when I was trying to mimic 
Terragen's rendering of height fields. Although obviously, our methods 
differ. I was calling mine cubic interpolation back then but I'm not so 
sure now... I'll have to re-check the source file to find out exactly 
what it is doing ;-)

Anyway, here are the results I got. I'm not uploading the source because 
it is not really readable as is, but if someone is interested I can 
clean it up...

Regards

-- 
Vincent


Post a reply to this message


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

Preview of image 'interpolations.jpg'
interpolations.jpg


 

From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 12:38:47
Message: <45eef8a7$1@news.povray.org>
Vincent Le Chevalier wrote:
> Funny, I did something similar a while ago, when I was trying to mimic 
> Terragen's rendering of height fields. Although obviously, our methods 
> differ. I was calling mine cubic interpolation back then but I'm not so 
> sure now... I'll have to re-check the source file to find out exactly 
> what it is doing ;-)
> 
> Anyway, here are the results I got. I'm not uploading the source because 
> it is not really readable as is, but if someone is interested I can 
> clean it up...
> 
> Regards

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 was hoping that Tek's blended cells technique would work well for 
height_fields, but as it turns out, those extra "Steps" don't look so 
good... maybe if other things were done to the pigment it would be good. 
Oh well :) I figured I should post it anyway.

~Sam


Post a reply to this message

From: Christoph Hormann
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 14:35:03
Message: <esn40c$b2d$1@chho.imagico.de>
Samuel Benge wrote:
> Hello everyone. I think there was a patch for this somewhere once... but 
> anyway.
> 
> Based on Tek's (very clever) blended cells pattern, I have made a small 
> macro which provides cubic interpolation between an image_map's pixels.

Are you sure this actually does bicubic interpolation?  The sample image 
looks somewhat strange.  Compare:

http://earth.imagico.de/img/hf_flat.jpg
http://earth.imagico.de/img/iso_cubic.jpg

BTW MegaPOV offers bicubic interpolation for image maps internally.

Christoph

-- 
Views of the Earth: http://earth.imagico.de/
Images, include files, tutorials: http://www.imagico.de/
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

From: Grassblade
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 15:05:00
Message: <web.45ef19bf625f00b5cc406eba0@news.povray.org>
I don't think that's the effect you were looking for. I have taken a look at
your code, and if I understand correctly, you are making interpolation pixel
per pixel, but with cubic interpolation you need 4 pixels, so if you are
repeating it on the next pixel, you are overlapping the previous
interplation. I've never tried it, but I think you should skip to the next
block of 4*4 pixels (or maybe 3*3, considering continuity/differentiability
of the block's edges).


Post a reply to this message

From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 16:15:12
Message: <45ef2b60@news.povray.org>
Christoph Hormann wrote:
> 
> Are you sure this actually does bicubic interpolation?

No, as a matter of fact, I am not sure. I figured since the cells are 
blended with cubic_map, that meant it was using cubic interpolation. I 
am not a great mathematician, by any means. I am more of a "math hacker".

> The sample image 
> looks somewhat strange.

Indeed. I was displeased with it.

> Compare:
> 
> http://earth.imagico.de/img/hf_flat.jpg
> http://earth.imagico.de/img/iso_cubic.jpg
> 
> BTW MegaPOV offers bicubic interpolation for image maps internally.
> 
> Christoph

This explains things... I am using MegaPOV v1.1! There was no 
interpolate 3 with this version. Thanks for the heads-up, Christoph!

~Sam


Post a reply to this message

From: Samuel Benge
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 16:21:25
Message: <45ef2cd5@news.povray.org>
Grassblade wrote:
> I don't think that's the effect you were looking for. I have taken a look at
> your code, and if I understand correctly, you are making interpolation pixel
> per pixel, but with cubic interpolation you need 4 pixels, so if you are
> repeating it on the next pixel, you are overlapping the previous
> interplation. I've never tried it, but I think you should skip to the next
> block of 4*4 pixels (or maybe 3*3, considering continuity/differentiability
> of the block's edges).
> 

Hmm, you may be right. Christoph pointed me toward a new version of 
MegaPOV which does what I want. If that works, then I won't improve my code.

~Sam


Post a reply to this message

From: Tek
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 7 Mar 2007 23:41:48
Message: <45ef940c@news.povray.org>
"Samuel Benge" <stb### [at] hotmailcom> wrote in message 
news:45eef8a7$1@news.povray.org...
> I was hoping that Tek's blended cells technique would work well for 
> height_fields, but as it turns out, those extra "Steps" don't look so 
> good... maybe if other things were done to the pigment it would be good. 
> Oh well :) 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. 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!

-- 
Tek
http://evilsuperbrain.com


Post a reply to this message

From: Vincent Le Chevalier
Subject: Re: cubic interpolation for image_maps (2 jpegs - 63kb)
Date: 8 Mar 2007 04:34:46
Message: <45efd8b6$1@news.povray.org>

> If I'm understanding correctly Vincent's technique was actually doing
> cubic interpolation, rather than just using cubic_wave (which isn't
> equivalent)...
> 

Well I don't know if it was cubic interpolation proper, but looking at
my code it seems that I was attempting to keep a continuous slope at
each vertex, and likely along the sides of the cells as well. Indeed
there is a cubic polynomial (degree 3 in x and 3 in y, in fact) looming
in there, but no cubic_wave...

For now my code is horribly mangled, because it is doing some other
things such as blending with another pattern, etc. and I never tried to
extract the interpolation from there. I'll try to single out and clean
up this part, then post it.

I'm not too sure about the efficiency of my technique either, I
implemented everything with functions, and thus it spends a lot of time
re-computing things that could have been stored... I don't remember
exactly why I did it like that. It seems I have another non-working
version where I tried to use arrays... There could have been something
about being unable to read an array from inside a function, I believe.

-- 
Vincent


Post a reply to this message

Goto Latest 10 Messages Next 7 Messages >>>

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