Dyes have a chemical interaction with the material they are coloring. It could be a strong chemical bond, ionic bond, etc.
Pigments are basically a dispersed solid particle. TiO2 would be a white pigment, not a dye. Carbon black is a pigment. Ultramarine blue is a blue pigment, while indigo is a dye.
My experience comes from foamed plastics. From what I have encountered. Urethane can use both pigments and dyes. Polyolefins typically use pigments only for coloring. Olefins will leach dyes, because there is very little chemical reactivity. Materials with oxygen and nitrogen bonds have a better success with dyes.
Pigments can be modified or compounded with dispersing agents to help color materials. High pigment loadings can begin to affect the physical properties of the colored material. Some pigments can be abrasive to equipment, such as TiO2 (white) & Chromium oxide green (Cr2O3).
Process conditions need to be understood before choosing the correct pigment or dye. Dyes typically use conjugated double bonds to produce color. Double bonds are reactive. Pigments can have heat stability and dispersion problems.