I need to determine what percentage of a given rendered image is background. Is there a simple way I can query that?
Do you need an accurate number or a fair estimation +/- some error?
If the latter is your case, you can simply traverse the viewport every, say, 10 columns/rows, and do a picking test. If the pick returns an actor, something is visible there. Doing this over the entire render area can give you a good enough proportion of background/non-background. Of course, you could do picking on every pixel, but that may hinder performance.
Also, if you know the background color beforehand, you can capture the viewport’s pixmap/image and test the pixels. If you have a, for example, black pixel, then it is background.
You can also render to a vtkImageData with alpha support and count how many pixels have alpha=0.
There isn’t anything in VTK that I am aware of that will compute this for you automatically.
Thank you all for the help. It took some doing, but I was able to do it by comparing with the background color.