aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze/AreaOfInterest/AOIFeatures.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/argaze/AreaOfInterest/AOIFeatures.py b/src/argaze/AreaOfInterest/AOIFeatures.py
index 669db72..020b050 100644
--- a/src/argaze/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze/AreaOfInterest/AOIFeatures.py
@@ -196,6 +196,43 @@ class AreaOfInterest(numpy.ndarray):
center_pixel = numpy.rint(self.center).astype(int)
cv.circle(frame, center_pixel, 1, color, -1)
+AOIFrameType = TypeVar('AOIFrame', bound="AOIFrame")
+# Type definition for type annotation convenience
+
+class AOIFrame():
+ """Define frame to draw into 2D AOI."""
+
+ def __init__(self, aoi: AreaOfInterestType, size: tuple):
+ """
+ .. warning::
+ Available for 2D AOI only."""
+
+ assert(aoi.dimension == 2)
+
+ self.__rX, self.__rY = size
+
+ # Init coordinates
+ self.__Sx = numpy.linspace(0., self.__rX/self.__rY, self.__rX)
+ self.__Sy = numpy.linspace(0., 1., self.__rY)
+
+ # Init frame
+ self.__frame = numpy.zeros((self.__rY, self.__rX))
+
+ def point_spread(self, point: tuple, sigma: float):
+ """Draw gaussian point spread into frame."""
+
+ div = -2 * sigma**2
+
+ x = point[0] / self.__rY # we use rY not rX !!!
+ y = point[1] / self.__rY
+
+ dX2 = (self.__Sx - x)**2
+ dY2 = (self.__Sy - y)**2
+
+ v_dX, v_dY = numpy.array(numpy.meshgrid(dX2, dY2)).reshape(2, -1)
+
+ return numpy.exp((v_dX + v_dY) / div).reshape(self.__rY, self.__rX)
+
AOISceneType = TypeVar('AOIScene', bound="AOIScene")
# Type definition for type annotation convenience