Background and Foreground extraction in image

Hi all,

I’m in need of extracting background and foreground colours in image. I tried with adrian’s OpenCV GrabCut: Foreground Segmentation and Extraction but this gives only foreground features. Please can you suggest me any library to extract the foreground and background colours.

Thanks in advance!!!