Most efficient way to get pixelcolors of an image?

D

defn noob

i want to process a large number of images and store their respective
pixels in a matrix.

what is the mostt efficient way of opening and checking them?
i doubt pygame is made for this purpose :)

i guess i could also use tkinter?


and why cant i print out matrix after getting the pixels? do i have to
deinit() pygame somehow?

import pygame
import sys
import os

print os.path.exists('C:/users/saftarn/desktop/images/bloba.bmp')

pygame.init()
screen = pygame.display.set_mode((800, 600))

image = pygame.image.load('C:/users/saftarn/desktop/images/bloba.bmp')
imrect = image.get_rect()
imrect = imrect.move(200, 200)

matrix = []

while 1:
pygame.display.flip()
screen.fill((255,255,255))
screen.blit(image, imrect)
pygame.event.wait()
event = pygame.event.wait()

for x in range(1, 301):
for y in range(1, 301):
matrix.append(screen.get_at((x, y)))

#print matrix
if event.type == pygame.QUIT:
#print matrix
sys.exit()
 
D

defn noob

this just shows a GUI that normally shows pictures but it doesnt show
any picture...


from PIL import Image

im = Image.open('C:/Users/saftarn/Desktop/images/giffer.gif')
im2 = Image.open('C:/Users/saftarn/Desktop/images/blob.jpg')

im.rotate(45).show()
im2.show()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top