Check out the Dissolve example. You will need to write a Filter plug-in.
Thanks for the reply. I looked into the dissolve example but it is not what i am looking for. I have an image with a design pattern on it. I want to fill the background which is white with a specific color and the design pattern which is gray in shade with a different color.
I was using the following approach:
Read each pixel of the image. If the pixel color falls in the range of white then fill it with a desired color else fill the pixel with other color.
But the resulting image is not acceptable as in some cases the design pattern is not very visible and in others, a few white pixels are left out and few gray pixels are filled with the color specified for white pixel. Also, this process is very time consuming.
Can you please suggest me a way to get the desired result.