2D data generator in C++ and MRF binary segmentation in Matlab