Fix the dsift version so that it matches Matlab

Still needs commenting to explain some of the decisions that
were made