Change color of specific pixels [Wand]

不问归期 提交于 2019-12-11 00:11:15

问题


So, I'm using Wand Python Library to mess around with some images.

I just want it to look at an image, pixel by pixel, and for each pixel that is a specific color, say '4d4d4d', replace that pixels color to something else, like '#00ff00'. That's it. I've thoroughly scoured the documentation and I can't for the life of me figure out how to do this.


回答1:


If anyone is interested the python code would be something like this:

from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color

with Drawing() as draw:
    draw.fill_color = Color('#00ff00')
    draw.color(x,y,'replace')
    with Image(filename='image.jpg') as img:
        draw(img)
        img.save(filename='new_image.jpg')


来源:https://stackoverflow.com/questions/33915785/change-color-of-specific-pixels-wand

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!