Getting number of pixels for fisheye view

Hi list,

to be able to integrate the luminance values of a fisheye view, I need the number of pixels in the image that are part of the view. I can take all pixels which have not a value of exactly 0 (as this should never exist for a valid material), but this seams to be not very accurate. I know that I can test if a pixel is inside the field of view using pcomb, which defines S(n) as zero for pixels outside the view, but I do not know how to access this value to count pixels inside the view. At the moment, the easiest way for me would be to render a fisheye pointing towards a 180 degree source without any geometry and count all none-black pixels, but I am sure that there must be a better way to test for the pixels' validity.

CU Lars.

Hi Lars,

If you just want a pixel count, you can use:

  pcomb -e 'lo=if(S(1)-1e-30,1,0)' input.pic | pvalue -h -H -pG -df | total -if

Beware that this will count all pixels for anything but -vth or -vta with very large -vv or -vh settings (>300 degrees or so).

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: January 27, 2009 7:36:13 PM PST

Hi list,

to be able to integrate the luminance values of a fisheye view, I need the number of pixels in the image that are part of the view. I can take all pixels which have not a value of exactly 0 (as this should never exist for a valid material), but this seams to be not very accurate. I know that I can test if a pixel is inside the field of view using pcomb, which defines S(n) as zero for pixels outside the view, but I do not know how to access this value to count pixels inside the view. At the moment, the easiest way for me would be to render a fisheye pointing towards a 180 degree source without any geometry and count all none-black pixels, but I am sure that there must be a better way to test for the pixels' validity.

CU Lars.

Hi Greg!

If you just want a pixel count, you can use:

    pcomb -e 'lo=if(S(1)-1e-30,1,0)' input.pic | pvalue -h -H -pG -df > total -if

Hm, thank You for this, now I am trying to figure out how it works. So you set the brightness to 1 if S(1) is greater then the very low treshold, else set it to 0, and sum up the pixel values (which are either 1 or 0, thus resulting in the n of pixels > 0)? This is very similar to what I did with grep, removing all values that have zero luminance, and counting the lines than. I was just not sure if it is really safe to rely on that pixels with zero luminance must be out of the view... But most probably they are, if I do not have a perfect absorber in my scene.

CU Lars.

Dump question: can't you work out which pixels are
outside the view area by calculating the vv and vh
of the pixel and comparing that with the value stored
in the image header?

Regards,
Thomas

···

On 28 Jan 2009, at 13:03, Lars O. Grobe wrote:

This is very similar to what I did with grep, removing all values that have zero luminance, and counting the lines than. I was just not sure if it is really safe to rely on that pixels with zero luminance must be out of the view... But most probably they are, if I do not have a perfect absorber in my scene.

can't you work out which pixels are
outside the view area by calculating the vv and vh
of the pixel and comparing that with the value stored
in the image header?

Well, I was thinking about doing that, but it is quite difficult to do
it. A pixel that sits "on the edge" is hard to count in this case, while
the pixel value, especially when used with a threshold, is easy to
extract and compare.

CU Lars.

Hi Lars,

Seems to me you have a pretty good grasp of what's going on with this calculation. You didn't really leave me anything else to explain... Since S(1) returns exactly 0 for off-view pixels, the 1e-30 threshold is set to allow for *very* small pixels, as you might have in a very high-resolution image.

Just beware that because the Radiance RGBE encoding doesn't have an exact representation of 1.0, that the actual count will be off (by -0.5% if I remember right).

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: January 28, 2009 5:03:00 AM PST

Hi Greg!

If you just want a pixel count, you can use:

    pcomb -e 'lo=if(S(1)-1e-30,1,0)' input.pic | pvalue -h -H -pG -df | total -if

Hm, thank You for this, now I am trying to figure out how it works. So you set the brightness to 1 if S(1) is greater then the very low treshold, else set it to 0, and sum up the pixel values (which are either 1 or 0, thus resulting in the n of pixels > 0)? This is very similar to what I did with grep, removing all values that have zero luminance, and counting the lines than. I was just not sure if it is really safe to rely on that pixels with zero luminance must be out of the view... But most probably they are, if I do not have a perfect absorber in my scene.

CU Lars.

So of course I ran into that problem of having perfectly black surfaces in my field of view. If ever anyone needs a way to get around this, here is my solution for now, using nothing but primitive text processing (and I am sure that the grep line could be written nicer):

N_PIXELS=`vwrays fisheye.hdr | grep -v -c "0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00"`

So I feed my image (fisheye.hdr) into vwray, which will produce viewpoint/direction vectors for each pixel. For pixels that are outside the view, it writes out three times zero. Grep -c counts those, but grep -v -c counts the lines NOT containing the six zero expressions. And this is the number of pixels inside my image's view.

Maybe someone finds it useful one day.

CU Lars.