summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--integralimg.go20
-rw-r--r--integralimg_test.go6
2 files changed, 13 insertions, 13 deletions
diff --git a/integralimg.go b/integralimg.go
index a197920..f53938d 100644
--- a/integralimg.go
+++ b/integralimg.go
@@ -115,7 +115,7 @@ func (i SqImage) At(x, y int) color.Color {
func (i SqImage) Set(x, y int, c color.Color) {
gray := uint64(color.Gray16Model.Convert(c).(color.Gray16).Y)
- Image(i).set64(x, y, gray * gray)
+ Image(i).set64(x, y, gray*gray)
}
// NewSqImage returns a new squared integral Image with the given bounds.
@@ -143,8 +143,8 @@ func (i Image) topLeft(r image.Rectangle) uint64 {
b := i.Bounds()
x := r.Min.X - 1
y := r.Min.Y - 1
- x = lowest(x, b.Max.X - 1)
- y = lowest(y, b.Max.Y - 1)
+ x = lowest(x, b.Max.X-1)
+ y = lowest(y, b.Max.Y-1)
if x < 0 || y < 0 {
return 0
}
@@ -153,9 +153,9 @@ func (i Image) topLeft(r image.Rectangle) uint64 {
func (i Image) topRight(r image.Rectangle) uint64 {
b := i.Bounds()
- x := lowest(r.Max.X - 1, b.Max.X - 1)
+ x := lowest(r.Max.X-1, b.Max.X-1)
y := r.Min.Y - 1
- y = lowest(y, b.Max.Y - 1)
+ y = lowest(y, b.Max.Y-1)
if x < 0 || y < 0 {
return 0
}
@@ -165,8 +165,8 @@ func (i Image) topRight(r image.Rectangle) uint64 {
func (i Image) bottomLeft(r image.Rectangle) uint64 {
b := i.Bounds()
x := r.Min.X - 1
- x = lowest(x, b.Max.X - 1)
- y := lowest(r.Max.Y - 1, b.Max.Y - 1)
+ x = lowest(x, b.Max.X-1)
+ y := lowest(r.Max.Y-1, b.Max.Y-1)
if x < 0 || y < 0 {
return 0
}
@@ -175,8 +175,8 @@ func (i Image) bottomLeft(r image.Rectangle) uint64 {
func (i Image) bottomRight(r image.Rectangle) uint64 {
b := i.Bounds()
- x := lowest(r.Max.X - 1, b.Max.X - 1)
- y := lowest(r.Max.Y - 1, b.Max.Y - 1)
+ x := lowest(r.Max.X-1, b.Max.X-1)
+ y := lowest(r.Max.Y-1, b.Max.Y-1)
return i[y][x]
}
@@ -188,7 +188,7 @@ func (i Image) Sum(r image.Rectangle) uint64 {
// Mean returns the average value of pixels in a rectangle
func (i Image) Mean(r image.Rectangle) float64 {
in := r.Intersect(i.Bounds())
- return float64(i.Sum(r)) / float64(in.Dx() * in.Dy())
+ return float64(i.Sum(r)) / float64(in.Dx()*in.Dy())
}
// Sum returns the sum of all pixels in a rectangle
diff --git a/integralimg_test.go b/integralimg_test.go
index ccc6fc2..885ff61 100644
--- a/integralimg_test.go
+++ b/integralimg_test.go
@@ -81,7 +81,7 @@ func TestSum(t *testing.T) {
{"small2", image.Rect(0, 0, 4, 4)},
}
- for _, c := range cases{
+ for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
sumimg := imgplus.sum(c.r)
sumint := integral.Sum(c.r)
@@ -121,7 +121,7 @@ func TestMean(t *testing.T) {
{"small2", image.Rect(0, 0, 4, 4)},
}
- for _, c := range cases{
+ for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
meanimg := imgplus.mean(c.r)
meanint := integral.Mean(c.r)
@@ -181,5 +181,5 @@ func (i grayPlus) sum(r image.Rectangle) uint64 {
func (i grayPlus) mean(r image.Rectangle) float64 {
in := r.Intersect(i.Bounds())
- return float64(i.sum(r)) / float64(in.Dx() * in.Dy())
+ return float64(i.sum(r)) / float64(in.Dx()*in.Dy())
}