haar

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 10 Imported by: 0

README

Haar

license go version go report

This project provides a Golang implementation of the Haar 2D transform, following an approach similar to imgSeek. The library can generate image hashes for indexing and similarity search in iqdb.

[!WARNING] Output from the Go package shows small deviations compared to the C reference. This does not affect the final result, and all images are successfully found. Refer to tests for specifics.

Installation

go get github.com/ezh0v/haar

Quick Start

Create your .go file. For example: main.go.

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/ezh0v/haar"
)

func main() {
	image, err := os.ReadFile("your_image_file.jpg")
	if err != nil {
		log.Fatal(err)
	}

	signature, err := haar.SignatureFromBlob(image)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(signature)
}

Run your program:

go run main.go

Motivation

Most booru sites need an image file to search. Danbooru can use an image's hash instead, which is much faster.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Signature

type Signature struct {
	Avgl [colorChannels]float64
	Sig  [colorChannels][haarCoefficients]int16
}

func SignatureFromBlob

func SignatureFromBlob(blob []byte) (*Signature, error)

func SignatureFromHash

func SignatureFromHash(hash string) (*Signature, error)

func (Signature) String

func (s Signature) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL