473,505 Members | 16,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Most efficient way to get pixelcolors of an image?

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()
Jul 2 '08 #1
3 1540
defn noob wrote:
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()
Most likely PIL (Pyhton Imaging Library).

-Larry
Jul 2 '08 #2
defn noob schrieb:
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 :)
Au contaraire, it is.

http://www.pygame.org/docs/ref/pixelarray.html

Diez
Jul 2 '08 #3
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()
Jul 2 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6111
by: Linus Nikander | last post by:
Having recently load-tested the application we are developing I noticed that one of the most expensive (time-wise) calls was my fetch of a db-connection from the defined db-pool. At present I fetch...
2
3872
by: Belmin | last post by:
Hi all, Wanted to know what is the most efficient way of doing a select query for mysql that only returns one value. For example: $mysqli->query('select count(*) from log'); $temprec =...
15
2310
by: Tor Erik Sønvisen | last post by:
Hi I need a time and space efficient way of storing up to 6 million bits. Time efficency is more important then space efficency as I'm going to do searches through the bit-set. regards tores
2
2296
by: Jim Kitterman | last post by:
I am looking for the most efficient way of searching a large xml document (> 14mg). If I could get some pointers in the right direction. I am using VB.NET. It is readonly.
1
1871
by: Al | last post by:
Hi, I need to store literally thousands if images and scanned document in the Database. I would like to know what is the most efficient algorithm both in terms of speed and storage for saving images...
1
1489
by: cwertman | last post by:
I have a document like so (Its actually a serilization of an Object) <Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">...
21
1976
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
1
3861
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
8
3828
by: secutos | last post by:
Programming Language: C#, .NET Framework 3.5 In this context, Form and App both describe a Microsoft Windows desktop application i'm creating. I'm creating a wordlist generator. I need to be able...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.