3d Depth of a pixel

Hi,

I need to know the z depth of each 3d point. I want an output image such that
color of each pixel stores the info of z-depth of the corresponding pixel .
in rpict i am confused in syntax. How do i use -z option ?

e.g.
rpict -x ResX -y ResY -z depth.hdr -vf camera.vp scene.oct > scene.hdr
???

Best Regards,
Brajesh Lal

···

________________________________

Hi!

I need to know the z depth of each 3d point. I want an output image such
that color of each pixel stores the info of z-depth of the corresponding
pixel .
in rpict i am confused in syntax. How do i use -z option ?

Didn't your command line work? I would probably avoid using the .hdr-extension for a depth-map, as its content are not hdr (in rgbe) but only floats.

Besides rpict, you could also use rtrace if you do not need the radiance/irradiance map but only the depth map. Probably I'd do that, as I could directly access the data then transparently without worrying about scanline ordering and reading binary files :slight_smile:

Look at the possible output values of rtrace (from 'man rtrace'):

···

--
(..)
-ospec Produce output fields according to spec. Characters
           are interpreted as follows:

                  o origin (input)

                  d direction (normalized)

(..)

                  L first intersection distance

(..)
                  p point of intersection
(..)
--
So lots of data you can get for finding the first point of intersection seen from a point of view. vwrays gives you ray directions to shoot at your scene.

Maybe this is helpful, maybe someone has a working example using rpict's -z?

Cheers, Lars.

Hi Brajesh,

Lars is right that you can use vwrays with rtrace to get more flexible output. The Z-buffer file is a string of binary floats, and not formatted as such. You need to pass it through pvalue if you want to produce a (grayscale) image. You can use the following sequence if you like:

  rpict -x ResX -y ResY -z depth.zbf -vf camera.vp scene.oct > scene.hdr
  pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf > depth.hdr

Notice the back-quotes above, which substitute the resolution output of getinfo -d on the command line. You can then view "depth.hdr" as a grayscale image or convert to color using falsecolor:

  falsecolor -l Depth -s auto -m 1 -i depth.hdr > depth_fc.hdr

If you don't want the grayscale image at all, you can combine your pvalue and falsecolor commands like so:

  pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf | falsecolor -l Depth -s auto -m 1 > depth_fc.hdr

Best,
-Greg

···

From: Brajesh Lal <[email protected]>
Date: March 17, 2011 4:33:10 AM PDT

Hi,

I need to know the z depth of each 3d point. I want an output image such that color of each pixel stores the info of z-depth of the corresponding pixel .
in rpict i am confused in syntax. How do i use -z option ?

e.g.
rpict -x ResX -y ResY -z depth.hdr -vf camera.vp scene.oct > scene.hdr ???

Best Regards,
Brajesh Lal

Hi Lars/ Greg,

I tried with small expression in a cal file.

As i know camera position and Camera view direction from camera.vp file.
I suppose rpict is similar to rtrace in terms of internal processing.

The depth of the 3d point will be = T *cos theta
I suppose " T " returns distance from camera to point of intersection as per
rayinit.cal

If CP = Normalized Vector from camera to Point of intersection ( Px, Py, Pz)

cos theta = (CP) dot product (normalized view vector)

therefore my cal file has
{
3dDepthshader.cal
}

red=T * ( (CPx * ViewX)+CPy * ViewY)+Cpz * ViewZ)) ;

is the correct way to compute ?

Anyway i will try with your given techniques too.

Best Regards, Brajesh Lal

···

________________________________
From: Greg Ward <[email protected]>
To: Radiance general discussion <[email protected]>
Sent: Thu, March 17, 2011 4:40:42 PM
Subject: Re: [Radiance-general] 3d Depth of a pixel

Hi Brajesh,

Lars is right that you can use vwrays with rtrace to get more flexible output.
The Z-buffer file is a string of binary floats, and not formatted as such. You
need to pass it through pvalue if you want to produce a (grayscale) image. You
can use the following sequence if you like:

    rpict -x ResX -y ResY -z depth.zbf -vf camera.vp scene.oct > scene.hdr
    pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf > depth.hdr

Notice the back-quotes above, which substitute the resolution output of getinfo
-d on the command line. You can then view "depth.hdr" as a grayscale image or
convert to color using falsecolor:

    falsecolor -l Depth -s auto -m 1 -i depth.hdr > depth_fc.hdr

If you don't want the grayscale image at all, you can combine your pvalue and
falsecolor commands like so:

    pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf | falsecolor -l Depth
-s auto -m 1 > depth_fc.hdr

Best,
-Greg

From: Brajesh Lal <[email protected]>
Date: March 17, 2011 4:33:10 AM PDT

Hi,

I need to know the z depth of each 3d point. I want an output image such that
color of each pixel stores the info of z-depth of the corresponding pixel .

in rpict i am confused in syntax. How do i use -z option ?

e.g.
rpict -x ResX -y ResY -z depth.hdr -vf camera.vp scene.oct > scene.hdr
???

Best Regards,
Brajesh Lal

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Brajesh.

It seems to me you want to undo the perspective distortion of the depth
buffer image in your cal file to produce a realistic elevation map. You
could also just use a parallel projection in your view specification and use
the "T" (ray length directly.

Regards,
Thomas

···

On Fri, Mar 18, 2011 at 10:36 AM, Brajesh Lal <[email protected]> wrote:

Hi Lars/ Greg,

I tried with small expression in a cal file.

As i know camera position and Camera view direction from camera.vp file.
I suppose rpict is similar to rtrace in terms of internal processing.

The depth of the 3d point will be = T *cos theta
I suppose " T " returns distance from camera to point of intersection as
per rayinit.cal

If CP = Normalized Vector from camera to Point of intersection ( Px, Py,
Pz)

cos theta = (CP) dot product (normalized view vector)

therefore my cal file has
{
3dDepthshader.cal
}

red=T * ( (CPx * ViewX)+CPy * ViewY)+Cpz * ViewZ)) ;

is the correct way to compute ?

Anyway i will try with your given techniques too.

Thanks Greg,

This worked for me

    rpict -x 640 -y 480 -z depth.zbf -vf camera.vp scene.oct > scene.hdr
    pvalue -r -h -df -b +y 480 +x 640 < scene.hdr depth.zbf > depth.hdr

I am able get the depth image after flip.

but when i tried falsecolor
i get error
bash:/opt/radiance/bin/falsecolor: /bin/csh: bad interpreter: Permission denied
Best Regards, Brajesh Lal

···

________________________________
From: Greg Ward <[email protected]>
To: Radiance general discussion <[email protected]>
Sent: Thu, March 17, 2011 4:40:42 PM
Subject: Re: [Radiance-general] 3d Depth of a pixel

Hi Brajesh,

Lars is right that you can use vwrays with rtrace to get more flexible output.
The Z-buffer file is a string of binary floats, and not formatted as such. You
need to pass it through pvalue if you want to produce a (grayscale) image. You
can use the following sequence if you like:

    rpict -x ResX -y ResY -z depth.zbf -vf camera.vp scene.oct > scene.hdr
    pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf > depth.hdr

Notice the back-quotes above, which substitute the resolution output of getinfo
-d on the command line. You can then view "depth.hdr" as a grayscale image or
convert to color using falsecolor:

    falsecolor -l Depth -s auto -m 1 -i depth.hdr > depth_fc.hdr

If you don't want the grayscale image at all, you can combine your pvalue and
falsecolor commands like so:

    pvalue -r -h -df -b `getinfo -d < scene.hdr` depth.zbf | falsecolor -l Depth
-s auto -m 1 > depth_fc.hdr

Best,
-Greg

From: Brajesh Lal <[email protected]>
Date: March 17, 2011 4:33:10 AM PDT

Hi,

I need to know the z depth of each 3d point. I want an output image such that
color of each pixel stores the info of z-depth of the corresponding pixel .

in rpict i am confused in syntax. How do i use -z option ?

e.g.
rpict -x ResX -y ResY -z depth.hdr -vf camera.vp scene.oct > scene.hdr
???

Best Regards,
Brajesh Lal

_______________________________________________
Radiance-general mailing list
[email protected]
http://www.radiance-online.org/mailman/listinfo/radiance-general

Hi Brajesh,

It sounds like you should download the latest version of falsecolor, which uses Perl instead of the C-shell. It seems that the C-shell is not properly installed on your system. I will send this to you in a private message, so you don't have to download the entire HEAD.

Best,
-Greg

···

From: Brajesh Lal <[email protected]>
Date: March 18, 2011 3:45:45 AM PDT

Thanks Greg,

This worked for me

    rpict -x 640 -y 480 -z depth.zbf -vf camera.vp scene.oct > scene.hdr
    pvalue -r -h -df -b +y 480 +x 640 < scene.hdr depth.zbf > depth.hdr

I am able get the depth image after flip.

but when i tried falsecolor
i get error
bash:/opt/radiance/bin/falsecolor: /bin/csh: bad interpreter: Permission denied

Best Regards, Brajesh Lal

You have to install CSH on your system. Use the distribution's package
management system and search for a csh or tcsh package.

Thomas

···

On Fri, Mar 18, 2011 at 11:45 AM, Brajesh Lal <[email protected]> wrote:

but when i tried falsecolor
i get error
bash:/opt/radiance/bin/falsecolor: /bin/csh: bad interpreter: Permission
denied

Hi!

but when i tried falsecolor i get error
bash:/opt/radiance/bin/falsecolor: /bin/csh: bad interpreter: Permission
denied

Do you have /bin/csh installed?

As Thomas mentioned, you can choose the projection using -vt with vwrays. That allows you to directly get z-depth for a parallel projection.

Cheers, Lars.