Python 更改特定像素的颜色[棒]
所以,我习惯于乱搞一些图像 我只想让它一个像素一个像素地看一幅图像,对于每一个特定颜色的像素,比如说“4D”,将该像素的颜色替换为其他颜色,比如“00ff00”。就这样。Python 更改特定像素的颜色[棒],python,colors,wand,Python,Colors,Wand,所以,我习惯于乱搞一些图像 我只想让它一个像素一个像素地看一幅图像,对于每一个特定颜色的像素,比如说“4D”,将该像素的颜色替换为其他颜色,比如“00ff00”。就这样。 我已经彻底浏览了文档,我一辈子都不知道该怎么做。如果有人感兴趣,python代码应该是这样的: from wand.image import Image from wand.drawing import Drawing from wand.color import Color with Drawing() as draw:
我已经彻底浏览了文档,我一辈子都不知道该怎么做。如果有人感兴趣,python代码应该是这样的:
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')
我根本不会说Python,但您需要将
fill
颜色设置为#00ff00
,然后使用设置为replace
的paint方法进行绘制。。。转到涵盖绘图的文档页面
,然后向下滚动至颜色和哑光