Movie Render Graph Landscape issues

Basically i’m looking for a PPM that will identify foreground and background objects (eg by custom stencil or tag ) render foreground white and background black. Then i can add it on at the end for a simple quick luma matte pass. Any ideas?