converted to scipy ndimages and doing transforms as array operations