Quantum confinement effects on optical transitions in nanodiamonds containing nitrogen vacancies