Better image coloring logic/algorithm

前端 未结 1 1994
[愿得一人]
[愿得一人] 2020-12-31 17:08

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

相关标签:
1条回答
  • 2020-12-31 17:41

    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.

    0 讨论(0)
提交回复
热议问题