在图像的特定部分填充颜色? [英] Fill color on specific portion of image?

查看:145
本文介绍了在图像的特定部分填充颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图片的特定区域填充特定颜色。

I want to fill specific color on specific area of an image.

EX:

>

在上面的 Joker 图像中,如果触摸Joker的头发,然后在头发上填充特定颜色或触摸鼻子,然后填充鼻子上的特定颜色等。我希望你能理解我想说的话。

In above Joker image, If touch on hair of Joker then fill specific color on hair Or touch on nose then fill specific color on nose.. etc. I hope may you understand what I am trying to say.

googling之后,可以使用 UIBezierPath CGContext Reference 但我是非常新的,我试图阅读本文档,但我不明白 (花更多的时间) ,我也有这个项目的时间限制。所以我不能花更多的时间。

After googling it's may be achieve by use of UIBezierPath or CGContext Reference but I am very new for it, I tried to read this documentation but I do not understand (take more time) anything also I have limit of time for this Project. So I can not spend more time on it.

我发现我们可以使用灌水算法。但我不知道如何使用我的情况。

Also I found that we can use Flood fill algorithm. But I don't know how to use in my case.


注意:我不想分割原始图片(例如头发,鼻子,帽子...等),因为如果我会这样做,因此我需要处理它的普通和视网膜设备,所以这个选项对我没有帮助。

NOTE: I don't want to divide original image (such like hair. nose, cap,...etc) because If I will do then there will be so many images in bundle so I need to handle it for both normal and retina device so this option is not helpful for me.

因此,请提供您宝贵的建议,并告诉我哪一种最适合我。 UIBezierPath CGContext Reference 如何在图片的特定部分填充颜色?和/或我们可以在区域的黑色边框下填充颜色吗?因为我是Quartz 2D编程的新人。

So please give me your valuable suggestion and also tell me which is best for me UIBezierPath or CGContext Reference? How can I fill color on specific portion of image? and/or can we fill color under the black border of area ? Because I am new at Quartz 2D Programming.

推荐答案

使用下面的Github库。帖子使用洪水填充算法: UIImageScanlineFloodfill

Use the Github library below. The post uses the flood fill algorithm : UIImageScanlineFloodfill

目标C说明: ObjFloodFill

如果你想看看算法的详细解释:递归用洪水填充算法(和僵尸和猫)解释

If you want to look at detailed explanation of the algorithm : Recursion Explained with the Flood Fill Algorithm (and Zombies and Cats)

其他语言的教程: Lode的计算机图形教程:Flood Fill

这篇关于在图像的特定部分填充颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆