[Radiance-general] extracting brightness values from picture

Prasanta Bhattarai bhattarai at simcenter.org
Mon Jan 7 06:48:17 PST 2008


Thanks Greg & Rob for your quick response.

I am using radiance on Linux and I am relatively a new user (both
radiance & Linux). I'm sure it's going to take some time for me to
understand Greg's syntax and be able to use it. So for now, I will try
to find a Mac and do calculations on photosphere. 

Thank You so much.

Prasanta



-----Original Message-----
From: Greg Ward [mailto:gward at lmi.net] 
Sent: Thursday, January 03, 2008 2:16 PM
To: Radiance general discussion
Subject: Re: [Radiance-general] extracting brightness values from
picture

Hello Prasanta,

As Rob points out, Photosphere may be used to compute the average  
value for a portion of an image.  The ximage viewer may be used in  
the same way.  If you need this computed in "batch mode" or want all  
the pixel values for a rectangular section, you can pass the picture  
through pcompos before sending it to pvalue.  (However, be aware that  
the -o option of pvalue will not work for pictures passed through  
pcompos.)

There is no convenient facility to get the pixels from a non- 
rectangular region of a picture, but using the following syntax:

	pvalue -o -h -H result.pic | rcalc -e 'cond=func($1,$2)' -e
'$1=179* 
(.265*$3+.670*$4+.065*$5)'

you can produce the luminance values for every pixel where func(x,y)  
is greater than zero.  Naturally, you must define this function also  
on the rcalc command line, and creating one for a polygon is not that  
easy.  An example function that would get luminance values along a  
diagonal extending from the lower-left of the image to the upper- 
right would be:

	-e 'func(x,y)=equal(x,y);equal(a,b):if(a-b+.5,b-a+.5,-1)'

I hope this makes some kind of sense.

If you have a way to create the mask you want on the image (in  
Photoshop or whatever), you can use the following nonsense to average  
over only these values.  (I assume the input mask is in PPM format,  
but it could be TIFF or whatever.)

        ra_ppm -r mask.ppm \
                 | pvalue -h -H -pG -df \
                 | rlam -if - "\!pvalue -h -H -o -b -df result.pic" \
                 | rcalc -if2 -of -e 'cond=$1-.5;$1=$2' \
                 | total -if -m

The backslash before the exclamation mark is only necessary for the C- 
shell, so you might have to remove that.

Best,
-Greg

> From: "Prasanta Bhattarai" <bhattarai at simcenter.org>
> Date: January 3, 2008 8:11:06 AM PST
> Hi all,
>
>  I have a question regarding extracting values from a pic file  
> (pvalue program?).
>
>  -           Is there a way to extract the values just for a  
> portion of picture (rather than getting it for a single pixel or  
> the whole picture)?
>
> -           Also, are we able to get values just for an irregular  
> polygon portion of the picture?
>
> Thanks a lot.
>
> Prasanta
>
> _________________________________________
>
> Prasanta Bhattarai





More information about the Radiance-general mailing list