Atomic and electronic structure of self-organized defects in epitaxial films of functional perovskite-type oxides