Often when doing image processing we need to change the color of the image pixels. This ultimately involves iterating through all the pixels of an image changing values as required. This can be a slow process, especially for large images.

When you want to change all pixels of one colour to another then you can avoid iterating over the entire image by instead changing the ColorModel. The ColorModel specifies the mapping between pixel values and their color. Changing this mapping allows us to change the color of pixels without manipulating the actual pixel value.

The following gives a simple example to demonstrate the concept by changing the ColorModel of the displayed images as the mouse is moved over it.