summaryrefslogtreecommitdiff
path: root/integralimg.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-03-03 16:52:56 +0000
committerNick White <git@njw.name>2020-03-03 16:52:56 +0000
commit0b999849a72a49c2d0b84c657705800a99242064 (patch)
tree46aecfd30736782076fa924604f7eacec03b302b /integralimg.go
parent6fa2c734929ca60488fb488dd31a39b89cfbe7d0 (diff)
Add GetHorizontalWindow function
Diffstat (limited to 'integralimg.go')
-rw-r--r--integralimg.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/integralimg.go b/integralimg.go
index 5cfbaf3..007e2c6 100644
--- a/integralimg.go
+++ b/integralimg.go
@@ -132,6 +132,18 @@ func (i I) GetVerticalWindow(x, width int) Window {
return Window { i[0][x], i[0][maxx], i[maxy][x], i[maxy][maxx], width, maxy }
}
+// GetHorizontalWindow gets the values of the corners of a horizontal
+// slice of an Integral Image, starting at y
+func (i I) GetHorizontalWindow(y, height int) Window {
+ maxy := y + height
+ maxx := len(i[0]) - 1
+ if maxy > len(i) - 1 {
+ maxy = len(i) - 1
+ }
+
+ return Window { i[y][0], i[y][maxx], i[maxy][0], i[maxy][maxx], maxx, height }
+}
+
// Sum returns the sum of all pixels in a Window
func (w Window) Sum() uint64 {
return w.bottomright + w.topleft - w.topright - w.bottomleft