Image Compare Toolkit
- Average
- Difference
- Part
- Block
import (
"github.com/gotokatsuya/ipare"
"github.com/gotokatsuya/ipare/util"
"github.com/gotokatsuya/ipare/algorithm/hash"
)
hash := ipare.NewHash()
// Default is DifferenceHash.
// hash.Algorithm = hash.NewAverage()
img1, _ := util.Open(imgPath1)
img2, _ := util.Open(imgPath2)
const threshold = 5
if distance := hash.Compare(img1, img2); distance <= threshold {
// similar image
} else {
// not same image
}
import (
"github.com/gotokatsuya/ipare"
"github.com/gotokatsuya/ipare/util"
"github.com/gotokatsuya/ipare/algorithm/pixel"
)
pixel := ipare.NewPixel()
// Default is DifferenceHash.
// pixel.Algorithm = pixel.NewBlock()
img1, _ := util.Open(imgPath1)
img2, _ := util.Open(imgPath2)
const threshold = 10
if distance := pixel.Compare(img1, img2); distance <= threshold {
// similar image
} else {
// not same image
}
$ go test github.com/gotokatsuya/ipare -v