moving density segmentation to separate hpp file.