version from http://graphics.stanford.edu/projects/densecrf/textonboost/classification.zip