POV-Ray : Newsgroups : povray.general : How to: use a image_map to retrieve single color? Server Time
19 May 2024 18:16:36 EDT (-0400)
  How to: use a image_map to retrieve single color? (Message 1 to 4 of 4)  
From: Impress
Subject: How to: use a image_map to retrieve single color?
Date: 4 Sep 2004 10:20:00
Message: <web.4139cdaf9bfdbeda6c4d2a2a0@news.povray.org>
Hi everyone,

well, I'm still on my quest to master pov-ray! I want to create a 2D array
of cubes where each cube will have a different single color according to an
image_map. I can easily create the array of cubes with a single color but
the part that I don't know how to do, it's to declare an image map and get
a single color inside the map!?

In a more general manner, I would like to know how to retrieve data inside
the image_map to be use as a generic data inside my POV-RAY code.. so that
I can use a map to store any kind of data that I can use later in the code.

regards,
Impress


Post a reply to this message

From: Warp
Subject: Re: How to: use a image_map to retrieve single color?
Date: 4 Sep 2004 15:30:23
Message: <413a17cf@news.povray.org>
Impress <yha### [at] nospamhotmailcom> wrote:
> well, I'm still on my quest to master pov-ray! I want to create a 2D array
> of cubes where each cube will have a different single color according to an
> image_map.

  Try this with an image called "test.jpg" (or whatever) in the same
directory as the scene file:

#declare Image =
  function { pigment { image_map { jpeg "test.jpg" } } }

#declare ImageWidth = 160;
#declare ImageHeight = 120;

#declare IndY = 0;
#while(IndY < ImageHeight)
  #declare IndX = 0;
  #while(IndX < ImageWidth)

    #declare ImageColor =
      Image(IndX/ImageWidth, IndY/ImageHeight, 0);

    box
    { -.4, .4 pigment { color ImageColor }
      translate <-ImageWidth/2 + IndX, 0,
                 -ImageHeight/2 + IndY>
    }

    #declare IndX = IndX+1;
  #end
  #declare IndY = IndY+1;
#end

camera { location <25, 200, -125> look_at 0 angle 35 }
light_source { <200, 500, -100>, 1 }



> In a more general manner, I would like to know how to retrieve data inside
> the image_map to be use as a generic data inside my POV-RAY code.. so that
> I can use a map to store any kind of data that I can use later in the code.

  Unfortunately image maps are not data containers which you can modify
freely. Even the trick above is just a workaround to get individual
values from the image map.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Manuel Mata
Subject: Re: How to: use a image_map to retrieve single color?
Date: 4 Sep 2004 16:30:00
Message: <web.413a2491e30d052ffb967eef0@news.povray.org>
>
> In a more general manner, I would like to know how to retrieve data inside
> the image_map to be use as a generic data inside my POV-RAY code.. so that
> I can use a map to store any kind of data that I can use later in the code.
>

Use my BMP macros at http://www.ignorancia.org/mmata/bmp.zip

Inside the zip u have a little tutorial in html format and some samples.

:/

         Manuel Mata Rueda
         http://www.ignorancia.org/mmata


Post a reply to this message

From: Impress
Subject: Re: How to: use a image_map to retrieve single color?
Date: 4 Sep 2004 18:20:01
Message: <web.413a3e6ee30d052f902216110@news.povray.org>
Thank you very much Warp! :)

This is very useful. I modify your example in order to use the value of the
image maps as an individual value. I translate each cube according to the
green component of the picture. It work well, and I think base on that
thing I can use the value to compute any kind of stuff! :)

here it's your example modified...


// create a regular point light source
#declare Image =
  function { pigment { image_map { png "firstMap.png" } } }

#declare ImageWidth = 160;
#declare ImageHeight = 120;

#declare IndY = 0;
#while(IndY < ImageHeight)
  #declare IndX = 0;
  #while(IndX < ImageWidth)

    #declare ImageColor =
      Image(IndX/ImageWidth, IndY/ImageHeight, 0);

    box
    { -.4, .4 pigment { color ImageColor }
      translate <-ImageWidth/2 + IndX, 10.0*ImageColor.green,
                 -ImageHeight/2 + IndY>
    }

    #declare IndX = IndX+1;
  #end
  #declare IndY = IndY+1;
#end

camera { location <25, 200, -125> look_at 0 angle 35 }
light_source { <200, 500, -100>, 1 }

// ------------

btw, I modified the filename to match the file that I put in my test dir.
but you probably figure it out... ;)

thanks!
impress/OPV


Post a reply to this message

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