Hello @kirkr5689!
The Summed Area Table node may be useful in this scenario: it returns the sum of all pixel values in the rectangle from the top left corner up to a pixel.
With this in mind, we can do the following:
- Get the sum of all pixel values for our source image
- Get the number of non-black pixels in our source image
- Divide the first by the second to get the average grayscale value of all non-black pixels
1 is done by sampling the pixel on the bottom right corner of the Summed Area Table node output.
2 is done by rounding all pixel values in the source image so that computing their sum effectively returns the number of non-black pixels, then doing the same as in 1
The result looks like this :

You can see it in action in the attached video. Changing the size of the shape does not affect the result, since we ignore pixels with a value of zero.
This returns the average height value. If you want the height middle point, then a simple Distance node may do the trick to eliminate pixels with a value of zero, then using the Min Max node as suggested by @davescm.

I hope this addresses your request!
Best regards.