I am developing an iOS app in which the user can change a part of an image\'s color, say a Tea Cup, by touching it. I am using Floodfill algorithm to fill colors so that the
In your example, let's call the pink color the "Color To Replace," and let's call the brown color the "Replacement Color." For each pixel in the destination, find the corresponding pixel in the source. See how it varies from the "Color to Replace". Now make similar adjustments to the "Replacement Color" and use that as the color at the current output pixel.
As an example, if the current source pixel is darker than the color to replace by 5 "v" units, then set the output pixel to the replacement color made darker by 5 "v" units. (And you'd want to make the same adjustments in hue and saturation, as well.)
You'll probably need to limit the range of colors you adjust so you aren't turning other objects a different color.