baseline c++ implementation of foreground background pixel labeling pipeline