C++ density segmentation.