Need to find occupied and not occupied regions in rendered image
I have a vtk renderwindow with few actors. In my application, I need to find the background region and the foreground region in the rendered image. I mean, I want a binary image that has the foreground and background regions marked. What is the best way to do this?