Abhinav Chauhan
Abhinav Chauhan

Reputation: 1960

How to replace a color in an image?

I'm in search of a simple algorithm to replace a color in an image with a different one like in this one-> http://en.wikipedia.org/wiki/File:Colorswaphelicon.png

I'm using VB.NET. Can a "flood fill" algorithm be applied for this purpose? Please provide a link if possible.

Greetings.

Upvotes: 0

Views: 5571

Answers (1)

Dmitry Shkuropatsky
Dmitry Shkuropatsky

Reputation: 3965

If you need to replace a color of a connected area then flood fill may work for you. For changing the color in the whole image check How to: Use a Color Remap Table and Recoloring Images topic.

Edit:

To replace all intensities of a color shade, you can check and replace the color hue (e.g. see How To Converting Colors Between RGB and HLS (HBS)). Specifically, colors with hue and saturation within a certain range of a source color can be changed to colors with original intensity and hue and saturation of the target color.

Also, you may find helpful How to change RGB color to HSV? and HSL in .net.

Upvotes: 3

Related Questions