Pygameで画像処理5
ノリノリです。RGB抽出を。
import pygame _gSrc = None pygame.init() pygame.display.set_mode((150, 150), 0, 32) pygame.display.set_caption("RGB抽出") _gScr = pygame.display.get_surface() tBuf = pygame.image.load("kenmo.jpg").convert() # RGB抽出 w, h = tBuf.get_size() for j in range(h): for i in range(w): colorA = tBuf.get_at((i, j)) # R成分抽出 tBuf.set_at((i, j), (colorA[0], 0, 0, 255)) while True: _gScr.blit(tBuf, (0, 0), tBuf.get_rect()) pygame.display.update() pygame.time.wait(10)