Added the functionality to compute the coefficients to penalize very similar neighbor pixels being labelled with different classes. Splitted the code in various functions