I am currently using radiance to render some pictures which I would like
to apply some post processing to. This will involve pasting an image
onto a specific location in the .pic file i have created.
In order to do this i need to know the location of certain points. I
know where they are in my 3D scene, but cannot work out a 3D to 2D
coordinate transform. I know that with a traditional pinhole perspective
projection i can work out new 2D coordinates if i know the old
coordinates, the focal point and the focal length. But i cant find any
way of determining what the focal length used by rpict is!
If anyone has, ideally, an equation for transforming 3D radiance
coordinates into 2D .pic coordinates based on an (x,y,z), view point and
view direction i would be incredibly grateful if you could let me know.
And if anyone could even help me determine the focal length i need that
would be a big help
Focal length is specified with the -vh and -vv options of rpict, which also controls the image aspect ratio. Knowing one from the other requires a specific image (film) size and format. For 35mm film, the formula is:
focal_length = 35/2 / tan(vv_angle/2)
Where vv_angle is the vertical view angle for a landscape picture. The horizontal angle is then given by:
hh_angle = 2 * atan(vv_angle/2 * 3/2)
To check your calcs, a 50mm lens in 35mm photography is equivalent to a Radiance view specification of:
-vh 49.6 -vv 35.3
(Remember that many trigonometric libraries including those used by Radiance's "calc" program deal in radians, and you need to convert this using 180/PI.)
I hope the above exercise makes it clear why I didn't choose focal length in definining views in rpict -- they don't make a lot of sense.
There are also Radiance library routines you can access from C-code. Check out the viewloc() function in src/common/image.c and some of the other routines there.
I am currently using radiance to render some pictures which I would like
to apply some post processing to. This will involve pasting an image
onto a specific location in the .pic file i have created.
In order to do this i need to know the location of certain points. I
know where they are in my 3D scene, but cannot work out a 3D to 2D
coordinate transform. I know that with a traditional pinhole perspective
projection i can work out new 2D coordinates if i know the old
coordinates, the focal point and the focal length. But i cant find any
way of determining what the focal length used by rpict is!
If anyone has, ideally, an equation for transforming 3D radiance
coordinates into 2D .pic coordinates based on an (x,y,z), view point and
view direction i would be incredibly grateful if you could let me know.
And if anyone could even help me determine the focal length i need that
would be a big help
Thanks a lot for you quick reply to my last question. Im sorry to bother
you again with what is probably another obvious question.
I have been spending a lot of time trying to use your 'viewloc()'
function in my program. I believe i know what most of the parameters
should be but i was hoping you could confirm (or correct) a few of my
assumptions as I cannot seem to produce any correct output.
Firstly, viewloc() is passed three variables ip, v and p. p is obviously
the input co-ordinates in the xyz used by the radiance coordinate
system. v is the details of the view. ip therefore must be the output
coordinates - are ip[0] and ip[1] the new x and y coordinates?
the only v setttings that i cannot figure out the origin of is hoff and
voff (the horizontal and vertical offsets). As i do not change many
rendering parameters with rpict (only -vp and -vd) i am assuming these
default to 0 - is this correct? i assume the rest of the v variables
(i.e. hvec, vvec, hn2 etc.) are calculated in the 'setview' function.
Finally, I have been passing ip[0] and ip[1] to the loc2pix function to
convert this location to a pixel coordinate. My resolution is the
default 512X512 and my -vv and -vh are also the default 45. Does this
mean that loc2pix will give me an (x,y) between 0 and 512?
Again sorry to bother you with this - i wouldnt ask unless i really
couldnt sort it out myself
Your help is greatly appreciated
Jon Bright
ps as a matter of interest i hear you are visiting my university
(Bristol) on sunday to meet, among other people, my supervisor (Alan
Chalmers). Small world isnt it!
···
Hi Jon,
Focal length is specified with the -vh and -vv options of rpict,
which
also controls the image aspect ratio. Knowing one from the other
requires a specific image (film) size and format. For 35mm film, the
formula is:
focal_length = 35/2 / tan(vv_angle/2)
Where vv_angle is the vertical view angle for a landscape picture.
The
horizontal angle is then given by:
hh_angle = 2 * atan(vv_angle/2 * 3/2)
To check your calcs, a 50mm lens in 35mm photography is equivalent to
a
Radiance view specification of:
-vh 49.6 -vv 35.3
(Remember that many trigonometric libraries including those used by
Radiance's "calc" program deal in radians, and you need to convert
this
using 180/PI.)
I hope the above exercise makes it clear why I didn't choose focal
length in definining views in rpict -- they don't make a lot of
sense.
There are also Radiance library routines you can access from C-code.
Check out the viewloc() function in src/common/image.c and some of
the
other routines there.
Good luck!
-Greg
> From: [email protected]
> Date: Mon Apr 28, 2003 12:25:41 PM US/Pacific
> To: [email protected]
> Subject: [Radiance-general] Transform from 3D to 2D Coordinates
> Reply-To: [email protected]
>
> Dear Radiance list,
>
> I am currently using radiance to render some pictures which I would
> like
> to apply some post processing to. This will involve pasting an
image
> onto a specific location in the .pic file i have created.
>
> In order to do this i need to know the location of certain points.
I
> know where they are in my 3D scene, but cannot work out a 3D to 2D
> coordinate transform. I know that with a traditional pinhole
> perspective
> projection i can work out new 2D coordinates if i know the old
> coordinates, the focal point and the focal length. But i cant find
any
> way of determining what the focal length used by rpict is!
>
> If anyone has, ideally, an equation for transforming 3D radiance
> coordinates into 2D .pic coordinates based on an (x,y,z), view
point
> and
> view direction i would be incredibly grateful if you could let me
know.
> And if anyone could even help me determine the focal length i need
that
> would be a big help
>
> Thanks a lot for your time
>
> Jon Bright
> _______________________________________________
> Radiance-general mailing list
> [email protected]
> http://www.radiance-online.org/mailman/listinfo/radiance-general
>
Since, as you point out, I will be at Bristol Univ. next week, anyway, we can chat about the viewloc() function while I'm there. I wasn't sure if you were one of Alan's students or somewhere else at the university. The -vs and -vl options default to 0, and you need not worry about them. You can use the stdview global or the STDVIEW macro defined in view.h to set the default view parameters. The ip[0] and ip[1] variables return image position on a [0-1) scale. You need to multiply these values by your image resolution to get the actual pixel coordinates, which is exactly what the loc2pix function is for. It seems like you have figured this all out, so I'm not sure what is and is not working for you at this point.
Thanks a lot for you quick reply to my last question. Im sorry to bother
you again with what is probably another obvious question.
I have been spending a lot of time trying to use your 'viewloc()'
function in my program. I believe i know what most of the parameters
should be but i was hoping you could confirm (or correct) a few of my
assumptions as I cannot seem to produce any correct output.
Firstly, viewloc() is passed three variables ip, v and p. p is obviously
the input co-ordinates in the xyz used by the radiance coordinate
system. v is the details of the view. ip therefore must be the output
coordinates - are ip[0] and ip[1] the new x and y coordinates?
the only v setttings that i cannot figure out the origin of is hoff and
voff (the horizontal and vertical offsets). As i do not change many
rendering parameters with rpict (only -vp and -vd) i am assuming these
default to 0 - is this correct? i assume the rest of the v variables
(i.e. hvec, vvec, hn2 etc.) are calculated in the 'setview' function.
Finally, I have been passing ip[0] and ip[1] to the loc2pix function to
convert this location to a pixel coordinate. My resolution is the
default 512X512 and my -vv and -vh are also the default 45. Does this
mean that loc2pix will give me an (x,y) between 0 and 512?
Again sorry to bother you with this - i wouldnt ask unless i really
couldnt sort it out myself
Your help is greatly appreciated
Jon Bright
ps as a matter of interest i hear you are visiting my university
(Bristol) on sunday to meet, among other people, my supervisor (Alan
Chalmers). Small world isnt it!