Quantum confinement and optical properties of nanostructured thin films