Fixed seg fault in resample, found seg fault in gradMag