From 0b999849a72a49c2d0b84c657705800a99242064 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 3 Mar 2020 16:52:56 +0000 Subject: Add GetHorizontalWindow function --- integralimg.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'integralimg.go') 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 -- cgit v1.2.1-24-ge1ad