It is a misconception to think that inside the lens (the medium that is different from vacuum in your case) photons travel with speed less then c.
There are a few things to clarify:
It is the wavefront that slows down inside the medium.
Photons always travel with speed c when measured locally in vacuum.
And photons do travel in vacuum inside the medium, inside the lattice, between the molecules and atoms, the photons travel in vacuum, with speed c when measured locally.
It is when the photons interact with the atoms in the lattice structure of the medium (the lens glass) that the individual photons' speed over the whole length of the glass will slow down compared to c. It is because the EM interactions between the photons and the atoms takes time. Now do not misunderstand please, the individual photons travel at speed c between the atoms in vacuum. It is when they interact with the atoms that slows them down (there is actually two theories on this site about this, one says there is phase shift, the other one says the photons get scattered elastically, but both ways, the interaction will cause the wavefront to slow down compared to c), relative to speed c.
Now, when we say that the individual photons speed on the whole length of the glass will slow down, that means that while they travel inside the glass, they interact with the atoms, and they go zigzag, not straight and the interaction takes time. Now, if you take the time when they enter the glass, and exit it, and count this time difference, and measure the straight path, you will get speed less then c. Of course, since the individual photons do not go straight, they zigzag.
Now, when the photons travel inside the glass, the wavefront will slow down. This is the same why the photons go zigzag, meaning, that the average path of the wavefront's photons is longer then the straight path. So you will get speed less then c for the wavefront inside the glass.
Now you say that when they exit the glass, they travel with speed c again so they sped up. In reality the photons go with speed c in vacuum in the glass and outside too. It is just that the individual photons go in zigzag (because of the interaction with the glass atoms) inside the glass and straight outside the glass. So they do not speed up, they always go with speed c in vacuum when measure locally. It is the wavefront that slows down inside the glass.
Even if you look at questions that confuse you, when somebody asks, when the photon gets emitted, why does it speed up to c from 0? It does not, in reality when the photon gets emitted, it already travels at speed c. Before the emission, the photon did not exist, so it did not have a speed.