added nearest neighbor segmap code