added code to detect foreground objects from background in the rgb image