initial fixes for category testing
added support for a general distance function: params.dist_fn; for euclidean distance, the computation now is done usinv conv2, which immidiately gave a better result. Computing the distances over a grid is NOT a good idea...