如何更改我的图像上的像素的一部分的alpha通道?

问题描述 投票:1回答:1

我想裁剪图像使用qazxsw POI,qazxsw POI和POI qazxsw(裁剪背景了学校图片)。

我的想法是部分图像关到比我需要的,然后操纵Alpha通道,使这些区域透明,因此所有我留下了是我所需要的零件的零件其他广场。我有一个开端的代码,但就死在相同的错误消息。

我试图做出某种圈面膜的裁剪面了,但口罩的概念仍然是国外对我,所以我想这会更容易些。

matplotlib

os.path
python image matplotlib rgb alpha
1个回答
0
投票

你会发现,很多与PIL /枕头容易。与菲奥娜的这一形象开始...

numpy

fig, ax = plt.subplots(1, 1)
# Show the image data in a subplot
ax.imshow(img, interpolation='none')
# Show the figure on the screen

row = len(img)
column = len(img[0])
for row in range(0, 231) :
    for column in range(0, 330) :
        img[row][column] = [0, 0, 0, 0]


fig.show()

Results: 26 for row in range(0, 231) : 27 for column in range(0, 330) : ---> 28 img[row][column] = [0, 0, 0] 29 30 IndexError: index 288 is out of bounds for axis 0 with size 288

这是我们创造阿尔法遮掩:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.