Optics of Inhomogeneous Thin Films with Defects: Application to Optical Characterization