Page 1 of 1

Convert [8*4] depth image into 32 depth image

Posted: 2011-12-07T10:25:33-07:00
by feranti
Hello everybody,

I have a specific need in image processing and I hope you can help me or orient me.
I need to output a 16 bits per channel (BPC) depth map from my 3D authoring tool (Virtools, for the record). I will be quick on details but I use a post-processing shader which generate this map :

Image

Internally in Virtools, this image has 32 BPC (and not 32 bits image: 8 BPC). But I cannot output it from Virtools in this pixel format. There is no way to do that.
The software only allows me to output it in 8 BPC and I lose all the depth details needed for an accurate use of this depthmap further in my workflow.
So I have modified my shader to write a grayscale 32 bits value in an 8 BPC image using the 8*4 bits of the image.
Here is the important part of the shader code :

Code: Select all

float distance ; // distance from the camera at this pixel
color.r = floor(distance)/256;
distance = frac(distance)* 256.0; // frac(x) is the fractional decimal part of the float [frac(x) = x - floor(x)] (for 23.6348 -> 0.6348)
color.g = floor(distance)/256;
distance = frac(distance)* 256.0;
color.b = floor(distance)/256;
distance = frac(distance)* 256.0;
color.a = floor(distance)/256;
which gives me this kind of psychedelic image :

Image

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

And now... finally :), here is a simplified schema of the conversion I need to do in ImageMagick :

Image

I know that ImageMagick connat handle 32 BPC images but if I could have a 16 BPC greyscale image, it would be just fine !

Here is a post which seems to be useful :
viewtopic.php?f=1&t=19752

Thanks for advance for your advices.

Re: Convert [8*4] depth image into 32 depth image

Posted: 2011-12-07T10:48:06-07:00
by fmw42
IM will handle 32-bits per channel if you compile IM with Q32 or 16-bits per channel if you install with Q16 (the default).

See binary releases available at http://www.imagemagick.org/download/www ... eases.html

See source code install at http://www.imagemagick.org/download/www ... ource.html
See advanced source code install notes at http://www.imagemagick.org/script/advan ... lation.php
See quantum depth at http://www.imagemagick.org/script/advan ... #configure

Re: Convert [8*4] depth image into 32 depth image

Posted: 2011-12-07T10:50:43-07:00
by fmw42
Sorry, posted to the wrong topic.

Re: Convert [8*4] depth image into 32 depth image

Posted: 2011-12-08T02:42:58-07:00
by feranti
Ok! Thanks for the 32 bits depth IM trick! This will be useful.

Anybody could help me on the command line to use to do the conversion ?