Pygame图像处理之添加杂音

"""给图像加噪音,其实就是在图像上随机打彩色像素点,属于图像处理"""

import pygame
import random

cyj = pygame.image.load("cyj.png")
width,height = cyj.get_size()

for i in range(1500):
    x = random.randrange(width)
    y = random.randrange(height)
    r = random.randint(0,255)
    g = random.randint(0,255)
    b = random.randint(0,255)
    
    cyj.set_at((x,y),(b,g,r))

pygame.image.save(cyj,"cyj_noise.png")

Pygame图像处理之添加杂音