Ejemplo n.º 1
0
// examineArea looks in the area surrounding x,y.
// if n points are above or n points are below, return keypoint=true.
func (d *Detector) isKeypoint(x int, y int) (keypoint bool) {
	// if within 3 of one of the edges, don't do anything (yet)
	if d.img.Bounds().Max.X-r < x {
		return false
	}
	if d.img.Bounds().Min.Y+r > y {
		return false
	}
	if d.img.Bounds().Min.X+r > x {
		return false
	}
	if d.img.Bounds().Max.Y-r < y {
		return false
	}

	abv := uint(0)
	bel := uint(0)
	for i := 0; i < 16; i++ {
		dx, dy := mask.DiamondOffset(i, r)

		// check if above or below threshold
		if d.Value(x+dx, y+dy, d) > (d.Value(x, y, d) + d.threshold) {
			abv++
		} else if d.Value(x+dx, y+dy, d) < (d.Value(x, y, d) - d.threshold) {
			bel++
		}
	}

	if abv > n {
		return true
	} else if bel > n {
		return true
	}
	return false
}
Ejemplo n.º 2
0
// pointVal returns 1 if the index in question is greater than point and
// 0 if it is less or equal to
func pointVal(i int, point image.Point, img image.Image, f PxVal) (val int) {
	dx, dy := mask.DiamondOffset(i, r)
	if f(point.X, point.Y, img) <= f(point.X+dx, point.Y+dy, img) {
		return 0
	} else {
		return 1 * pow(2, i)
	}
}