In the case of lead iodide, the band gap is such that it absorbs and reflects light in the blue region of the visible spectrum, while allowing yellow light to be transmitted or reflected. Therefore, our eyes perceive lead iodide as yellow.
It's important to note that slight variations in the composition, crystal structure, or impurities within a compound can also influence its color.