有什么好的颜色使图像上的文字突出的算法呢? [英] What's good algorithm for getting color to make text on image outstanding?

查看:100
本文介绍了有什么好的颜色使图像上的文字突出的算法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在图像下方,照片是背景,照片中央有一个字符 Iniesta。
但是该字符很难读,因为颜色不好。
是否有任何好的算法可以使颜色变色,使图像上的字符突出?

For instance, below image, a photo is background, and there is a character 'Iniesta' at the center of the photo. But the character is some hard to read because the color is not good. Is there any good algorithm for getting color to make character on image outstanding?

推荐答案

而不是制作矩形背景(实际上不是这样)看起来非常不错),您可以使用以下技巧:

Instead of making a rectangular background (that indeed doesn't look very nice) you could use this trick:


  • 选择两种对比色(例如白色和黑色)

  • 使用第一种颜色和一支宽笔(例如5像素)描边文本

  • 绘制使用第二种颜色填充的文本

如果您不能用宽笔描画文本,则可以用小偏移量多次绘制文本。例如(Python)

If you cannot stroke the text with a wide pen an alternative is drawing the text multiple times with small offsets; e.g. (Python)

for dy in range(-3, 4):
    for dx in range(-3, 4):
        draw_text(color1, x+dx, y+dy, message)
draw_text(color2, x, y, message)

例如一个像素边框看起来像这样...

For example a one-pixel border would look like this...

这篇关于有什么好的颜色使图像上的文字突出的算法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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