POV-Ray : Newsgroups : povray.newusers : Image function Server Time
23 Nov 2024 06:43:54 EST (-0500)
  Image function (Message 1 to 10 of 10)  
From: kurtz le pirate
Subject: Image function
Date: 28 May 2023 10:49:57
Message: <64736a15$1@news.povray.org>
Hello,


I'm racking my brain over this problem :
I'd like to have a function that can give me the color of a pixel in an
image (the equivalent of "eval_pigment") to fill a plane.


I've tried a lot of things but none of them work.

What I would like :

plane {
 y, 0
 pigment { color imageFunction(x,y,z) }
 }

With the function like that :
#declare imageFunction = function {
 pigment {
  image_map { jpeg imageName }
  rotate -x*90
  translate <-0.5, 0, -0.5>
  scale <imageWidth, 1, imageHeight>
  }
 }

Of corse, this does not work and i get parse errors but the idea is here.

So can you tell me if this "kind of thing" is possible or not before I
go *crazy* ?



(@﹏@)


-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

From: Thomas de Groot
Subject: Re: Image function
Date: 28 May 2023 11:22:48
Message: <647371c8$1@news.povray.org>
Op 28-5-2023 om 16:49 schreef kurtz le pirate:
> Hello,
> 
> 
> I'm racking my brain over this problem :
> I'd like to have a function that can give me the color of a pixel in an
> image (the equivalent of "eval_pigment") to fill a plane.
> 
Why not use eval_pigment? See:

https://news.povray.org/povray.binaries.images/thread/%3Cweb.52ede41cd6fcc84f7a3e03fe0%40news.povray.org%3E/?mtop=395729

I must have the macro somewhere... I shall send it tomorrow from my 
other machine.

-- 
Thomas


Post a reply to this message

From: Bald Eagle
Subject: Re: Image function
Date: 28 May 2023 16:10:00
Message: <web.6473b4558a5f67eb1f9dae3025979125@news.povray.org>
Once again, I'm asking WHY?

Kenneth tried to do this circular process a while back - but if all you're doing
is tiling a plane with an image, then just use an image_map pigment and don't
specify "once".

If you do, however, have some future use for the function version, then you need
to invoke it like this:

plane {
  y, 0
  pigment { function { imageFunction (x,y,z) } }
  }

eval_pigment is just a macro wrapper for the same kinda thing, which means that
will be an extra layer, and another layer on top of that to un-macro-ify it (if
even possible) for use in the way you want.


- BE

kurtz le pirate <kur### [at] gmailcom> wrote:
> Hello,
>
>
> I'm racking my brain over this problem :
> I'd like to have a function that can give me the color of a pixel in an
> image (the equivalent of "eval_pigment") to fill a plane.
>
>
> I've tried a lot of things but none of them work.
>
> What I would like :
>
> plane {
>  y, 0
>  pigment { color imageFunction(x,y,z) }
>  }
>
> With the function like that :
> #declare imageFunction = function {
>  pigment {
>   image_map { jpeg imageName }
>   rotate -x*90
>   translate <-0.5, 0, -0.5>
>   scale <imageWidth, 1, imageHeight>
>   }
>  }
>
> Of corse, this does not work and i get parse errors but the idea is here.
>
> So can you tell me if this "kind of thing" is possible or not before I
> go *crazy* ?
>
>
>
> (@﹏@)
>
>
> --
> Kurtz le pirate
> Compagnie de la Banquise


Post a reply to this message

From: Thomas de Groot
Subject: Re: Image function
Date: 29 May 2023 02:30:33
Message: <64744689$1@news.povray.org>
Op 28/05/2023 om 17:22 schreef Thomas de Groot:
> Op 28-5-2023 om 16:49 schreef kurtz le pirate:
>> Hello,
>>
>>
>> I'm racking my brain over this problem :
>> I'd like to have a function that can give me the color of a pixel in an
>> image (the equivalent of "eval_pigment") to fill a plane.
>>
> Why not use eval_pigment? See:
> 
>
https://news.povray.org/povray.binaries.images/thread/%3Cweb.52ede41cd6fcc84f7a3e03fe0%40news.povray.org%3E/?mtop=395729
> 
> I must have the macro somewhere... I shall send it tomorrow from my 
> other machine.
> 

I don't know if this is what you want to do, but provide an image map 
and play with this test scene...


-- 
Thomas


Post a reply to this message


Attachments:
Download 'eval_pigmenttest_carpet.pov.txt' (5 KB)

From: kurtz le pirate
Subject: Re: Image function
Date: 29 May 2023 12:10:57
Message: <6474ce91@news.povray.org>
On 28/05/2023 22:06, Bald Eagle wrote:
> Once again, I'm asking WHY?

apologies...

I didn't describe what I wanted to do very well.
I'll try to be clearer.

a) I recover the color of a point <x,0,z> of a source image.
b) I transform this point into a new point <x1,0,z1>.
c) I give this new point the color taken in a)

In fact, I already have a code that does this, but only with the checker
pattern. Not very sexy !

For the moment the plan is drawn like this :
plane {
  y,0
  pigment { function { fnPigment(x,z) } }
  }

hence my request for a function()

Instead of the checker, the original distorted image.



The "geometric" transformation is the result of applying function.
Two examples with f(z) = z^2 and f(z) = sin(z)/(z+1).

Brighter ?




ps : I'm going to watch "Eval_pigmentTest_carpet.pov". Thanks Thomas

-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message


Attachments:
Download 'map01_cfunctions_9.png' (21 KB) Download 'map01_cfunctions_1.png' (33 KB)

Preview of image 'map01_cfunctions_9.png'
map01_cfunctions_9.png

Preview of image 'map01_cfunctions_1.png'
map01_cfunctions_1.png


 

From: Bald Eagle
Subject: Re: Image function
Date: 29 May 2023 13:55:00
Message: <web.6474e69a8a5f67eb1f9dae3025979125@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:
> On 28/05/2023 22:06, Bald Eagle wrote:
> > Once again, I'm asking WHY?
>
> apologies...
>
> I didn't describe what I wanted to do very well.
> I'll try to be clearer.
>
> a) I recover the color of a point <x,0,z> of a source image.
> b) I transform this point into a new point <x1,0,z1>.
> c) I give this new point the color taken in a)
>
> In fact, I already have a code that does this, but only with the checker
> pattern. Not very sexy !


Ah, excellent.
This makes much more sense now.

> The "geometric" transformation is the result of applying function.
> Two examples with f(z) = z^2 and f(z) = sin(z)/(z+1).
>
> Brighter ?

Much better.
Have coded a geometric inversion function?   I would be highly interested in
that for use with Clifford tori and such.

Anyway, here's what I think you need to do if you want to modify an image_map
using a function, and still have the full color.

Then all you have to do is modify the function.

------------------------------------------------------------------------



#version 3.8;
global_settings {assumed_gamma 1.0}
default {finish {diffuse 1}}

// +am3 +a0.01 +ac0.90 +r3


camera {
 location <0, 5, -0.01>
 right     x*image_width/image_height
 up y
 look_at <0, 0, 0>
}

light_source {<0, 100, 0> rgb 1.0}

sky_sphere {pigment {rgb 1}}


#declare ImageMap = function {pigment {image_map {png "plasma2.png"} rotate
x*90} }


#declare FullColorTexture =
  texture {
   pigment {
          average
          pigment_map {
              [
                  function { ImageMap (x, y, z).red }
                  color_map {
                      [ 0 red 0 ]
                      [ 1 red 5 ]
                  }
              ]
              [
                  function { ImageMap (x, y, z).green }
                  color_map {
                      [ 0 green 0 ]
                      [ 1 green 5 ]
                  }
              ]
              [
                  function { ImageMap (x, y, z).blue }
                  color_map {
                      [ 0 blue 0 ]
                      [ 1 blue 5 ]
                  }
              ]
                [
                  function { ImageMap (x, y, z).filter }
                  color_map {
                      [ 0 blue 0 ]
                      [ 1 blue 5 ]
                  }
              ]
                [
                  function { ImageMap (x, y, z).transmit }
                  color_map {
                      [ 0 blue 0 ]
                      [ 1 blue 5 ]
                  }
              ]
    } // end pigment map
   } // end pigment
  } // end layered texture

plane {
 y, 0
 texture {FullColorTexture }
}


Hope that works the way you want.

- BW


Post a reply to this message


Attachments:
Download 'imagemapfunction.pov.dat' (2 KB)

From: Tor Olav Kristensen
Subject: Re: Image function
Date: 29 May 2023 20:25:00
Message: <web.647541d58a5f67eb8991e8e489db30a9@news.povray.org>
kurtz le pirate <kur### [at] gmailcom> wrote:
> On 28/05/2023 22:06, Bald Eagle wrote:
> > Once again, I'm asking WHY?
>
> apologies...
>
> I didn't describe what I wanted to do very well.
> I'll try to be clearer.
>
> a) I recover the color of a point <x,0,z> of a source image.
> b) I transform this point into a new point <x1,0,z1>.
> c) I give this new point the color taken in a)
>
> In fact, I already have a code that does this, but only with the checker
> pattern. Not very sexy !
>
> For the moment the plan is drawn like this :
> plane {
>   y,0
>   pigment { function { fnPigment(x,z) } }
>   }
>
> hence my request for a function()
>
> Instead of the checker, the original distorted image.
>...

Hi Kurtz

The code here may be relevant for what you are trying to achieve:

From: Tor Olav Kristensen
Subject: Source code for "Using functions to distort images"
Date: 2006-05-12 18:48:59
http://news.povray.org/povray.text.scene-files/thread/%3C4470ee5b%40news.povray.org%3E

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: jr
Subject: Re: Image function
Date: 30 May 2023 13:40:00
Message: <web.647633ec8a5f67ebb49d80446cde94f1@news.povray.org>
hi,

"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> ...
> The code here may be relevant for what you are trying to achieve:

neat, thanks for posting this link.


regards, jr.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Image function
Date: 30 May 2023 20:20:00
Message: <web.647691b78a5f67eba9e5460e89db30a9@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> > ...
> > The code here may be relevant for what you are trying to achieve:
>
> neat, thanks for posting this link.

No problem jr. I am glad if I can help with solving someone's problem.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: kurtz le pirate
Subject: Re: Image function
Date: 1 Jun 2023 12:44:28
Message: <6478caec$1@news.povray.org>
Thanks guys. Two leads to explore
and in 2006... i don't think i already knew "functions" !




-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message

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