[Radiance-general] Alpha channel/object matte
Giulio Antonutto
Giulio.Antonutto at arup.com
Fri Nov 19 11:48:08 CET 2004
Hi,
I am not really sure which is your question... I missed the 1st
emails...sorry ;-)
But if I am right you are trying to create an alpha channel from a rendered
picture,
I would do this way:
1) generate your rendering: image
2) generate a mask: you can just create an image with only the object and
-av 1 1 1,
then use "pcomb -e 'vo=if(li(1),1,0)' object > mask " to create a BW image
with 0 and 1.
3) apply the mask to the 1st image:
pcomb -e 'ro=if(li(2),ri(1),0);go=if(li(2),gi(1),0);bo=if(li(2),bi(1),0)'
image mask > filtered
in general all the functions are defined in rayinit.cal, into the radiance
libs...
hope it helps/works,
giulio
-----Original Message-----
From: radiance-general-bounces at radiance-online.org
[mailto:radiance-general-bounces at radiance-online.org]On Behalf Of Kirk
Thibault
Sent: 18 November 2004 17:21
To: Radiance general discussion
Subject: Re: [Radiance-general] Alpha channel/object matte
Thanks for the info. I guess that means I need to know what format
the "Z" file is and how the information is arranged. I generated one
using the -z option of rpict and then just tried to look at it ("less")
and i was given the message - "This file may be a binary file - view
anyway?". I said yes and got gobbledyguck.
I also tried the strategy of rendering a background only image (this
renders just the HDR image wrapped around my scene) and then a
"objects" render that includes the background and the objects. If you
use pcomb to take the difference between the two images, you should
more or less be left with the objects only and presumably you could
then do another pcomb to make the image 2 bit. I tried something like:
pcomb -s -1 background_image object_image > diff_image <<<(takes the
difference between the two images)
then
pcomb -e 'ro=if(ri(1)=0,0,1);go=if(gi(1)=0,0,1;b0=if(bi(1)=0,0,1)' >
matte_image
the idea being that if the pixel value in the "diff" image was 0 this
would be a pixel which was the same in the background image and the
object image (i.e., part of the background) versus anything else, which
would be an object. This has limitations, but in general I was trying
to say "if the pixel in the diff image is black, it is part of the
background, keep it black, otherwise if it is not black, make it white.
Needless to say, I got a command line error saying that a ')' was
expected. I'm guessing that this means i used the "if" function
incorrectly within the context of pcomb, or in general. The obvious
shortcoming of this crude method is that if the diff image contains a
black pixel value in the object area, it will remain black and thus not
be part of the object matte. Definitely not robust. The Z file info
sounds like the way to go in this respect so I look forward to an
explanation of how to tap into it.
Can you tell I'm learning Radiance and Unix simultaneously? :)
Thanks folks!
kirk
On Nov 18, 2004, at 6:33 AM, Peter Apian-Bennewitz wrote:
> Kirk Thibault wrote:
>
>> Hi Folks,
>>
>> Is there a straightforward way to generate alpha channel or object
>> matte 8 bit grayscale images in radiance for compositing purposes?
>>
> Hi Kirk,
>
> At least not automatically by rpict itself. rayshade (and likely
> others raytracers too) generate an optional alpha channel, and I
> nagged Greg to add an optional fourth channel to the image format in (
> - hang on, a quick seach in my mail folders..) June 1993. That never
> made it, since a change of format would have produced various nasty
> side effects. The main reason for my wish was to paste the image into
> existing (tpically outside) scenery easily. With fisheye HDRs being
> on-vogue now, surrounding the model with an HDR source-primitive is a
> better way to solve that merging problem.
>
> So, you'll have to generate a z-file (-z option), use the z-value to
> differentiate between an object hit (alpha opaque) and infinity (alpha
> transparent) and convert that to whatever image format you need.
> Suitable pcomb/pfilt/pvalue scripts are left as an exercise to the
> reader ...
>
> -Peter
>
> --
> pab-opto, Freiburg, Germany, http://www.pab-opto.de
> [see web page to check digital email signature]
>
>
>
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-general
_______________________________________________
Radiance-general mailing list
Radiance-general at radiance-online.org
http://www.radiance-online.org/mailman/listinfo/radiance-general
___________________________________________________________________
Electronic mail messages entering and leaving Arup business
systems are scanned for acceptability of content and viruses.
More information about the Radiance-general
mailing list