颜色叠加算法 [英] Color overlaying algorithm
问题描述
我正在寻找一种在现有图片上叠加颜色的算法。与以下应用程序类似的东西(墙画家): http:// itunes.apple.com/us/app/wall-painter/id396799182?mt=8
I'm looking for an algorithm to overlay a color on top of existing picture. Something similar to the following app (wall painter): http://itunes.apple.com/us/app/wall-painter/id396799182?mt=8
我想要一个类似的功能,所以我可以画一个墙现有图片并将它们更改为不同的颜色。
I want a similar functionality so I can paint walls in an existing picture and change them to a different color.
我可以在yuv或rgb模式下工作。
I can work both in yuv or rgb mode.
推荐答案
要成功地在图片中绘制墙壁,您必须执行以下两个步骤:
To successfully paint the walls in a picture, you have to do two steps:
-
找到图片中墙的边界(选择要着色的图像部分)
Find the boundary of the wall within the picture (select the part of the image to be colored)
将所需颜色应用于所选区域
Apply the desired color to the selected area
第一步是困难的部分。它类似于Photoshop的魔棒工具。事实上,搜索魔杖算法会出现一些好文章,例如文章。
The first step is the hard part. It similar to what Photoshop's magic wand tool would do. And indeed a search for magic wand algorithm turns up a few good articles such as this article with Objective-C code.
第二步更容易,可以用 CGContextSetBlendMode
和 CGContextDrawImage
实现。
The second step is much easier and can be achieve with CGContextSetBlendMode
and CGContextDrawImage
.
这篇关于颜色叠加算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!