-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1d.py
54 lines (36 loc) · 1.04 KB
/
test1d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sys, numpy
from pygpu import *
from pygpu.types import *
import pygame
from pygame.locals import *
from pyglew import *
pygame.display.init()
surface = pygame.display.set_mode((512,512), OPENGL|DOUBLEBUF)
glewInit()
initPyGPU()
@gpu(size = lambda x: x.size) ##(x.size[0], x.size))
def columnSum(im=RImage, p=Int):
return im(p)
@gpu(size = lambda im,n: (512,512)) ##(x.size[0], x.size))
def columnSumDynamic(im=RGBImage, n=Int, p=Position):
res = float3(0,0,0)
for i in range(n):
res += im(p + float2(0,i))
return res/float3(n,n,n)
image = loadImage("data/naomi.jpg", RGBImage)
glDisable(GL_DEPTH_TEST)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0, 512, 0, 512, -1, 1)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
while True:
#check for quit'n events
event = pygame.event.poll()
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
break
glClear(GL_COLOR_BUFFER_BIT)
res = columnSumDynamic(image,100)
print res
res.show()
pygame.display.flip()