blob: 883a95d6f4c914acf6a986a1eb47ad82b0293bff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
from operationscore.PixelMapper import *
import util.Geo as Geo
class GaussianMapper(PixelMapper):
"""GaussianMapper is a PixelMapper which weights pixels around an event proportional to a
gaussian surface. Specify:
<Height> -- The height of the gaussian surface
<Width> -- The width of the gaussian surface
<MinWeight> -- the minimum weight event that can be returned
<CutoffDist> -- the maximum radius considered
"""
def mappingFunction(self, eventLocation, screen):
returnPixels = []
[x,y] = eventLocation
potentialPixels = screen.pixelsInRange(x-self.CutoffDist, \
x+self.CutoffDist)
for (x,pixel) in screen.pixelsInRange(x-self.CutoffDist, \
x+self.CutoffDist):
pixelDist = Geo.dist(pixel.location, eventLocation)
if pixelDist < self.CutoffDist:
w = Geo.gaussian(pixelDist, self.Height, 0, self.Width)
if w > self.MinWeight:
returnPixels.append((pixel, w))
return returnPixels
|