diff options
author | Nick White <git@njw.name> | 2020-08-03 16:35:51 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2020-08-03 16:35:51 +0100 |
commit | 55560bf16ee70335dcb72f80a3f6dacfb88d7ae8 (patch) | |
tree | 913fddfe8e730985a321476e86f184971994f176 | |
parent | eca5854cfec5ec4a13312bd5fdae81f66be3a673 (diff) |
Improve documentation
-rw-r--r-- | README | 11 | ||||
-rw-r--r-- | integralimg.go | 8 |
2 files changed, 4 insertions, 15 deletions
@@ -11,17 +11,6 @@ by running `go get rescribe.xyz/integralimg` and documentation can be read with the `go doc` command or online at <https://pkg.go.dev/rescribe.xyz/integralimg>. -## Bugs - -The standard deviation and mean functions don't produce precisely -the same result as those run on non integral images. The difference -is small enough that it has little effect for most uses, but it -ought to be identical. - -## TODO - -Write tests for the package. - ## Contributions Any and all comments, bug reports, patches or pull requests would diff --git a/integralimg.go b/integralimg.go index f53938d..3585703 100644 --- a/integralimg.go +++ b/integralimg.go @@ -180,23 +180,23 @@ func (i Image) bottomRight(r image.Rectangle) uint64 { return i[y][x] } -// Sum returns the sum of all pixels in a rectangle +// Sum returns the sum of all pixels in a section of an image func (i Image) Sum(r image.Rectangle) uint64 { return i.bottomRight(r) + i.topLeft(r) - i.topRight(r) - i.bottomLeft(r) } -// Mean returns the average value of pixels in a rectangle +// Mean returns the average value of pixels in a section of an image func (i Image) Mean(r image.Rectangle) float64 { in := r.Intersect(i.Bounds()) return float64(i.Sum(r)) / float64(in.Dx()*in.Dy()) } -// Sum returns the sum of all pixels in a rectangle +// Sum returns the sum of all pixels in a section of an image func (i SqImage) Sum(r image.Rectangle) uint64 { return Image(i).Sum(r) } -// Mean returns the average value of pixels in a rectangle +// Mean returns the average value of pixels in a section of an image func (i SqImage) Mean(r image.Rectangle) float64 { return Image(i).Mean(r) } |