i've been trying figure out way present gabor patches onto black background on pygame, , have struggled so. can each element independently - a) can make black background screen appear, , b) can run bunch of code separately , gabor patch appear on own separate screen:
import numpy np import matplotlib.pyplot plt import matplotlib.cm cm size = np.linspace(-np.pi,np.pi,200) xgrid, ygrid = np.meshgrid(size, size) gaussian = np.exp(-(xgrid/2)**2-(ygrid/2)**2) sine = np.sin(xgrid*10) gabor = sine * gaussian plt.imshow(gabor,cm.gray) plt.show()
but able make gabor patch appear in pre-determined location on black pygame screen itself. i've watched few youtube tutorials on presenting images in pygame , have tried following method (no success):
from win32api import getsystemmetrics import sys import pygame pygame.locals import * import numpy np import matplotlib.pyplot plt import matplotlib.cm cm import matplotlib.image mpimg import time pygame.init() clock= pygame.time.clock() fps =30 screenwidth=getsystemmetrics(0) screenheight=getsystemmetrics(1) fullscreensize=(screenwidth/2,screenheight/2) gamedisplay=pygame.display.set_mode(fullscreensize) black = (0,0,0) while true: event in pygame.event.get(): if event.type == pygame.quit or event.type == keyup: pygame.quit() size = np.linspace(-np.pi,np.pi,200) xgrid, ygrid = np.meshgrid(size, size) gaussian = np.exp(-(xgrid/2)**2-(ygrid/2)**2) sine = np.sin(xgrid*10) gabor = sine * gaussian x = ((screenwidth/2) * 0.3) #left on x-axis y = ((screenheight/2) * 0.45) #mid-height on screen #my attempt specify gabor presented on left side of screen def leftgabor (x,y): gamedisplay.blit(gabor,(x,y)) gamedisplay.fill(black) gamedisplay.blit(gabor,(x,y)) leftgabor(x,y) pygame.display.update() clock.tick(fps)
using code, happens black screen pops up. nothing else. please point out i'm doing wrong , point me in right direction?
your gabor object not blittable object. can make out array co-orinates , values each co-ordinte, co-ordinates run minus pi pi, , there 200 in each direction. neede map these screen, , everywehere there point, draw usinhg pygame.draw.line function.
Comments
Post a Comment