"""
红化,绿化,蓝化,黄化,青化,品红化,灰度化图形,pygame.surfarray.array3d像素级操作示例
"""
import pygame
from pygame.locals import *
import numpy as np
def reden(image):
"""去掉绿色和蓝色,保留红色像素值"""
def greenen(image):
"""去掉红色和蓝色,保留绿色像素值"""
def magentaen(image):
"""去掉绿色,保留红色和蓝色像素值"""
def cyanen(image):
"""去掉红色,保留绿色和蓝色像素值"""
def yellowen(image):
"""去掉蓝色,保留红色,绿色,即黄色"""
image_3Darray = pygame.surfarray.array3d(image) # 转为矩阵
def blueen(image):
"""去掉红色和绿色,保留蓝色像素值"""
def revertrgb(image):
"""倒序RGB像素值"""
def revertcolor(image):
"""反转图像"""
def grayen(image):
"""灰度图像,灰度算法"""
def 柔化(image):
"""柔化,这柔化效果"""
image = pygame.image.load("images/背景1.png")
width ,height = image.get_size()
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption('pygame.surfarray.array3d像素级操作by李兴球')
screen.blit(image,(0,0))
pygame.display.update()
pygame.time.wait(1000)
image = 柔化(image)
screen.blit(image,(0,0))
pygame.display.update()
pygame.time.wait(1000)
如需要查看完整源代码,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

