POV-Ray : Newsgroups : povray.general : Projecting a photograph on to a 3D model Server Time
25 Dec 2024 01:47:17 EST (-0500)
  Projecting a photograph on to a 3D model (Message 1 to 9 of 9)  
From: Mark Karaska
Subject: Projecting a photograph on to a 3D model
Date: 5 Dec 2007 14:20:30
Message: <4756f9fe@news.povray.org>
Hi,
I have a photograph of a city taken from a plane showing the sides of 
buildings. I'd like to project the photo on to my 3D model of the city.

Can POVRAY do this?
Thanks,
Mark


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Projecting a photograph on to a 3D model
Date: 5 Dec 2007 14:34:35
Message: <4756fd4b$1@news.povray.org>
Mark Karaska escribió:
> Hi,
> I have a photograph of a city taken from a plane showing the sides of 
> buildings. I'd like to project the photo on to my 3D model of the city.
> 
> Can POVRAY do this?

Any object can have an image_map. It's a bit tricky to get a different 
image on each side of a box{}, I'm sure somebody else could help you 
more on how to do that.

If you want to really "project" an image into a complex object (think on 
how a real projector would work on a non-planar surface), try Rune's 
illusion.inc.
http://runevision.com/show.asp?id=96


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Projecting a photograph on to a 3D model
Date: 5 Dec 2007 16:55:01
Message: <web.47571dd1a7accdbbc150d4c10@news.povray.org>
"Mark Karaska" <mka### [at] mitreorg> wrote:
> Hi,
> I have a photograph of a city taken from a plane showing the sides of
> buildings. I'd like to project the photo on to my 3D model of the city.
>
> Can POVRAY do this?
> Thanks,
> Mark

Yes, but it can be tricky.
1) You need the proportions of the building sizes of the model to match fairly
close to the actual buildings.  Even so, you can expect some pixel 'leak'
around hard edges of the model as the image map is just a bunch of square
pixels with a finite resolution, shouldn't be too much of a concern though.

2) You need to get the orientation of the image_map correct.

3) This one's a bit tougher maybe.  A standard image map is projected parallel,
all the pixels run continuously straight, however, the image will have been
taken from a camera, so will not have a parallel projection.  The larger the
viewing angle of the camera, the more distorted this can be.  If it's a fairly
tight angle (i.e. was taken with a zoom lens), then the differences may be
unnoticeable.  However if it is a larger angle projection, you may need to look
at distorting the image map.  The best way for this may be to turn it into a
function and apply it with spherical warping.  For example, lets assume your
image is square, and was taken with a 60deg field of view.  A full spherical
map will cover 360deg across and 180deg up/down, so you need to you need to
scale your image to suit this.  Spherical image map is 1unit x 1unit, your
image should be scaled so it is 60/360 units by 60/180 units in the center of
the 1x1 square to be mapped.  Then you need to get the spherical centre placed
properly (i.e, where the camera was in relation to the real buildings) and
oriented properly.

Hope this makes sense somewhat.

-tgq


Post a reply to this message

From: Tim Attwood
Subject: Re: Projecting a photograph on to a 3D model
Date: 5 Dec 2007 21:04:46
Message: <475758be@news.povray.org>
> I have a photograph of a city taken from a plane showing the sides of 
> buildings. I'd like to project the photo on to my 3D model of the city.

In general, no, there are issues involving perspective,
image location, and differences in apparent size versus actual size.

But you can perspective correct portions of an image and then use
those to map things like building faces, individually. It's just a lot of
work.

NASA uses some software that correlates depth info from stereographic
photos, and location info, and forms a mosaic 3D model for it's mars
rovers, but it's buggy and very clunky.


Post a reply to this message

From: Chris B
Subject: Re: Projecting a photograph on to a 3D model
Date: 6 Dec 2007 06:08:58
Message: <4757d84a$1@news.povray.org>
"Tim Attwood" <tim### [at] comcastnet> wrote in message 
news:475758be@news.povray.org...
>> I have a photograph of a city taken from a plane showing the sides of 
>> buildings. I'd like to project the photo on to my 3D model of the city.
>
> In general, no, there are issues involving perspective,
> image location, and differences in apparent size versus actual size.
>
> But you can perspective correct portions of an image and then use
> those to map things like building faces, individually. It's just a lot of
> work.
>

Hi Mark,

There is a simple (albeit very crude) way to correct the proportions of the 
image. You can set up a 'projector' using a light source and a filtered 
image. As Trevor mentioned, you'd need the 3D model to fairly accurately 
represent the building shapes and you'll probably still get leaching around 
the edges, so I'm not claiming that this will be anywhere near perfect (just 
fairly quick to do).

Blocks representing the buildings should be white.

A single light source should be located roughly where your camera was 
relative to the city and the image should be placed a little way in front of 
it, oriented so that it's perpendicular to the line between the light and 
the centre of the image. Use 'filter all 1' to get the light to project the 
image. The building surfaces visible in the image will be illuminated with 
the appropriate image, surfaces hidden from your camera will remain white.

If you have more than one image you can have more than one projector, so, if 
your plane flew around the city and you got 4 photos, you might get a fairly 
complete coverage, although it may take a bit of fiddling around to align 
them correctly.

Here's a very simple example that projects an image onto a box and a 
cylinder.

camera {location <-0.74, 0.65, -3> look_at 0}
box {0,1 pigment {rgb 1}}
cylinder {0,y,0.4 pigment {rgb 1} translate -x}

light_source {<0,0,-400> color rgb 1}
plane {z,-300
  pigment {
    image_map {jpeg "Your_Image.jpg"
      filter all 1 once}
    translate <-0.5,-0.5,0>
  }
}

Hope this helps,

Regards,
Chris B.


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Projecting a photograph on to a 3D model
Date: 6 Dec 2007 13:47:27
Message: <475843bf$1@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:4757d84a$1@news.povray.org...
> light_source {<0,0,-400> color rgb 1}
> plane {z,-300
>  pigment {
>    image_map {jpeg "Your_Image.jpg"
>      filter all 1 once}
>    translate <-0.5,-0.5,0>
>  }
> }

AFAIK 'filter all' will only work with indexed images.
However, there's no need for such hacks, it's perfectly possible to 
'perspective-transform' the image_map with functions.  As Nicolas Alvarez 
mentioned, Rune's illusion.inc can be used for just that.

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

From: Chris B
Subject: Re: Projecting a photograph on to a 3D model
Date: 6 Dec 2007 15:20:27
Message: <4758598b$1@news.povray.org>
"Zeger Knaepen" <zeg### [at] povplacecom> wrote in message 
news:475843bf$1@news.povray.org...
> "Chris B" <nom### [at] nomailcom> wrote in message 
> news:4757d84a$1@news.povray.org...
>> light_source {<0,0,-400> color rgb 1}
>> plane {z,-300
>>  pigment {
>>    image_map {jpeg "Your_Image.jpg"
>>      filter all 1 once}
>>    translate <-0.5,-0.5,0>
>>  }
>> }
>
> AFAIK 'filter all' will only work with indexed images.

Hi Zeger,

In fact "filter all" works with the jpeg as posted. 'filter' followed by a 
number seems to demand an indexed image.

> However, there's no need for such hacks, it's perfectly possible to 
> 'perspective-transform' the image_map with functions.  As Nicolas Alvarez 
> mentioned, Rune's illusion.inc can be used for just that.
>

Agreed that it's possible. I never said it wasn't possible to do it the 
other ways, but it does get round a number of problems that you would run 
into doing it other ways (unless Rune has foreseen them all - which he may 
have done. He's a clever guy :-)), like getting your head round what sort of 
projection you'd need for each building in the model and working out how to 
suppress the backside of an image applied to an object.

Whichever way one approaches the problem the results would be pretty 
imperfect because there are likely to be surfaces that were hidden from the 
original view point of the camera and that therefore don't show up on the 
original photo, so I figured it was worth suggesting an extremely low effort 
alternative that may just happen to fit Mark's needs.

Regards,
Chris B.


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Projecting a photograph on to a 3D model
Date: 6 Dec 2007 15:27:00
Message: <47585b14$1@news.povray.org>
"Chris B" <nom### [at] nomailcom> wrote in message 
news:4758598b$1@news.povray.org...
> Hi Zeger,
>
> In fact "filter all" works with the jpeg as posted. 'filter' followed by a 
> number seems to demand an indexed image.

really? wow, I wish I knew that sooner, would've saved me a lot of averaged 
pigment_map's :p

thanks!

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

From: Kenneth
Subject: Re: Projecting a photograph on to a 3D model
Date: 7 Dec 2007 16:05:00
Message: <web.4759b452a7accdbb78dcad930@news.povray.org>
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:

> If you want to really "project" an image into a complex object (think on
> how a real projector would work on a non-planar surface), try Rune's
> illusion.inc.
> http://runevision.com/show.asp?id=96

Thanks for this link; I hadn't yet seen these .inc files of Rune's.  Lots of
useful stuff there.

Ken W.


Post a reply to this message

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