Average of the pixels

I am developing Volume Rendering applications using 3D Texture Mapping.For each 2D Slices rendered, I want to find the intensity value of the each pixel at position(i,j) of each slice which are greater than a particular thresold and find average of it.

How to do that.

RAJESH.R