Melanin, produced by melanocytes in the choroid, helps absorb stray light and prevent light scattering. This process optimizes visual clarity and improves the quality of the image projected onto the retina.