Crossover from large to small polarons across the metal-insulator transition in manganites