Very strong mindfulness can be compared to detergent. Just as we must wash a dirty plate before we can use it to eat healthy food, we must clear away impure mental states, such as hatred, greed, and delusion, before we can develop pure states, such as generosity, loving~ friendliness, and wisdom.
The Buddha compared the process to what happens when we dye cloth: “0 bhikkhus, just as an impure, stained cloth, when dyed blue, yellow, or red, takes a bad hue and an impure color because the cloth is impure and stained, in the same manner, when the mind is defiled, a bad state can be expected. Just as a pure, unstained cloth, when dyed blue, yellow, or red, takes a pure color and a bright hue, so when the mind is pure, a good state can be expected.” As the sutta tells us, when the householder Upali’s mind had been purified so that it was ready, receptive, elated, and confident, the Buddha taught him the Four Noble
Just as a clean cloth with all marks removed would take dye evenly, so too, while the householder Upali sat there, the spotless immaculate vision of the Dhamma arose in him.
(tr. Bhikkhu Bodhi)