added patch2ind.m