### Install goimagehash Go Package Source: https://pkg.go.dev/github.com/corona10/goimagehash/index This snippet shows the command to install the goimagehash library using the Go modules system. It ensures you have the latest version of the library available for your project. ```go go get github.com/corona10/goimagehash ``` -------------------------------- ### Go Image Hashing Example Source: https://pkg.go.dev/github.com/corona10/goimagehash/index Demonstrates how to use goimagehash to calculate and compare image hashes. It covers AverageHash, DifferenceHash, and ExtAverageHash, including distance calculations and hash serialization/deserialization. ```go package main import ( "bufio" "bytes" "fmt" "image/jpeg" "os" "github.com/corona10/goimagehash" ) func main() { file1, _ := os.Open("sample1.jpg") file2, _ := os.Open("sample2.jpg") defer file1.Close() defer file2.Close() img1, _ := jpeg.Decode(file1) img2, _ := jpeg.Decode(file2) hash1, _ := goimagehash.AverageHash(img1) hash2, _ := goimagehash.AverageHash(img2) distance, _ := hash1.Distance(hash2) fmt.Printf("Distance between images: %v\n", distance) hash1, _ = goimagehash.DifferenceHash(img1) hash2, _ = goimagehash.DifferenceHash(img2) distance, _ = hash1.Distance(hash2) fmt.Printf("Distance between images: %v\n", distance) width, height := 8, 8 hash3, _ := goimagehash.ExtAverageHash(img1, width, height) hash4, _ := goimagehash.ExtAverageHash(img2, width, height) distance, _ = hash3.Distance(hash4) fmt.Printf("Distance between images: %v\n", distance) fmt.Printf("hash3 bit size: %v\n", hash3.Bits()) fmt.Printf("hash4 bit size: %v\n", hash4.Bits()) var b bytes.Buffer foo := bufio.NewWriter(&b) _ = hash4.Dump(foo) foo.Flush() bar := bufio.NewReader(&b) hash5, _ := goimagehash.LoadExtImageHash(bar) } ``` -------------------------------- ### Get ImageHash Kind in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index Returns the kind (algorithm type) of the ImageHash. This method indicates which hashing algorithm was used to generate the hash. It is called on an ImageHash pointer and returns a Kind. ```go func (h *ImageHash) GetKind() Kind ``` -------------------------------- ### Get Extended ImageHash Kind in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index Returns the kind (algorithm type) of the ExtImageHash. This method indicates which hashing algorithm was used to generate the extended hash. It is called on an ExtImageHash pointer and returns a Kind. ```go func (h *ExtImageHash) GetKind() Kind ``` -------------------------------- ### Flatten 2D Pixel Array to 1D - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms The FlattenPixels function converts a 2D slice of float64 pixel data into a 1D slice. It takes the 2D pixel array and the starting x and y coordinates for flattening. This is often used to simplify data structures before further processing. ```Go func FlattenPixels(pixels [][]float64, x int, y int) []float64 FlattenPixels function flattens 2d array into 1d array. ``` -------------------------------- ### Flatten 2D Pixel Array - FlattenPixels Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/transforms Converts a 2D array of float64 (representing pixels) into a 1D array. It takes the 2D pixel data, and the x and y coordinates from which to start flattening, returning a single slice of float64. This can be useful for simplifying data structures. ```go func FlattenPixels(pixels [][]float64, x int, y int) []float64 { // Implementation details... return nil } ``` -------------------------------- ### ExtImageHash Functions (v1.1.0) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Introduces functions for generating `ExtImageHash` with specified width and height, and loading/dumping hash data from/to I/O readers. ```APIDOC ## ExtImageHash Functions (v1.1.0) ### Description This section details functions for generating `ExtImageHash` with custom dimensions and for serialization/deserialization. ### Methods #### `ExtAverageHash(img image.Image, width, height int) (*ExtImageHash, error)` - **Description**: Computes the average hash of an image with specified width and height. - **Type**: Function #### `ExtDifferenceHash(img image.Image, width, height int) (*ExtImageHash, error)` - **Description**: Computes the difference hash of an image with specified width and height. - **Type**: Function #### `ExtPerceptionHash(img image.Image, width, height int) (*ExtImageHash, error)` - **Description**: Computes the perception hash of an image with specified width and height. - **Type**: Function #### `LoadExtImageHash(b io.Reader) (*ExtImageHash, error)` - **Description**: Loads an `ExtImageHash` from an `io.Reader`. - **Type**: Function ### Type: ExtImageHash #### `Bits() int` - **Description**: Returns the number of bits in the hash. - **Type**: Method #### `Dump(w io.Writer) error` - **Description**: Dumps the `ExtImageHash` to an `io.Writer`. - **Type**: Method ``` -------------------------------- ### Create New Extended ImageHash in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index Creates a new ExtImageHash with specified hash values, kind, and bit size. It takes a slice of uint64 hash values, a Kind, and an int bit size as input and returns a pointer to an ExtImageHash. ```go func NewExtImageHash(hash []uint64, kind Kind, bits int) *ExtImageHash ``` -------------------------------- ### Create New ImageHash in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index Creates a new ImageHash with a specified hash value and kind. It takes a uint64 hash value and a Kind as input and returns a pointer to an ImageHash. ```go func NewImageHash(hash uint64, kind Kind) *ImageHash ``` -------------------------------- ### ImageHash Generation and Comparison Source: https://pkg.go.dev/github.com/corona10/goimagehash/index This section covers the core functionalities for creating and comparing image hashes using the `ImageHash` type. ```APIDOC ## ImageHash Operations ### Description Functions for generating and comparing standard image hashes. ### Functions - **AverageHash**(img image.Image) (*ImageHash, error) Computes the average hash of an image. - **DifferenceHash**(img image.Image) (*ImageHash, error) Computes the difference hash of an image. - **PerceptionHash**(img image.Image) (*ImageHash, error) Computes the perception hash of an image. - **LoadImageHash**(b io.Reader) (*ImageHash, error) Loads an image hash from a reader. ### Methods - **(h *ImageHash) Distance**(other *ImageHash) (int, error) Calculates the Hamming distance between two ImageHashes. - **(h *ImageHash) Dump**(w io.Writer) error Dumps the ImageHash to a writer. - **(h *ImageHash) Bits**() int Returns the bit size of the ImageHash. - **(h *ImageHash) GetHash**() uint64 Returns the uint64 hash value. - **(h *ImageHash) GetKind**() Kind Returns the kind of hash. - **(h *ImageHash) ToString**() string Returns the string representation of the hash. ``` -------------------------------- ### RGB to Grayscale Conversion Functions (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/transforms_tab=versions Offers functions to convert an image.Image to grayscale represented as float64 slices. Two versions are available: a fast version that takes a pointer to a float64 slice and a standard version. ```Go func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) func Rgb2Gray(colorImg image.Image) [][]float64 ``` -------------------------------- ### ImageHash Functions (v1.1.0) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Provides functions for loading and dumping `ImageHash` data from/to I/O readers, and retrieving the number of bits in the hash. ```APIDOC ## ImageHash Functions (v1.1.0) ### Description This section details functions for serializing and deserializing `ImageHash` objects, and accessing hash bit information. ### Methods #### `LoadImageHash(b io.Reader) (*ImageHash, error)` - **Description**: Loads an `ImageHash` from an `io.Reader`. - **Type**: Function ### Type: ImageHash #### `Bits() int` - **Description**: Returns the number of bits in the hash. - **Type**: Method #### `Dump(w io.Writer) error` - **Description**: Dumps the `ImageHash` to an `io.Writer`. - **Type**: Method ``` -------------------------------- ### Extended ImageHash Dump Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Dumps the binary representation of an ExtImageHash to an io.Writer. Available in v1.1.0 and later. ```Go func (h *ExtImageHash) Dump(w io.Writer) error ``` -------------------------------- ### Go Fast DCT2DFast64 Transformation Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions An accelerated implementation of the 2-dimensional Discrete Cosine Transform (DCT) for float64 data. It operates on a pointer to a slice of float64 and is designed for efficiency in image processing tasks within the goimagehash transforms package. ```Go func DCT2DFast64(input *[]float64) ``` -------------------------------- ### ImageHash Dump Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Dumps the binary representation of an ImageHash to an io.Writer. Available in v1.0.0 and later. ```Go func (h *ImageHash) Dump(w io.Writer) error ``` -------------------------------- ### Create Perception Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Generates a Perception Hash for a given image. This function is available in v0.1.0 and later. It takes an image.Image and returns an ImageHash and an error. ```Go func PerceptionHash(img image.Image) (*ImageHash, error) ``` -------------------------------- ### Extended ImageHash Generation and Comparison Source: https://pkg.go.dev/github.com/corona10/goimagehash/index This section covers the extended functionalities for creating and comparing image hashes using the `ExtImageHash` type, allowing for custom widths and heights. ```APIDOC ## ExtImageHash Operations ### Description Functions for generating and comparing extended image hashes with specified dimensions. ### Functions - **ExtAverageHash**(img image.Image, width, height int) (*ExtImageHash, error) Computes the extended average hash of an image with given width and height. - **ExtDifferenceHash**(img image.Image, width, height int) (*ExtImageHash, error) Computes the extended difference hash of an image with given width and height. - **ExtPerceptionHash**(img image.Image, width, height int) (*ExtImageHash, error) Computes the extended perception hash of an image with given width and height. - **LoadExtImageHash**(b io.Reader) (*ExtImageHash, error) Loads an extended image hash from a reader. ### Methods - **(h *ExtImageHash) Distance**(other *ExtImageHash) (int, error) Calculates the Hamming distance between two ExtImageHashes. - **(h *ExtImageHash) Dump**(w io.Writer) error Dumps the ExtImageHash to a writer. - **(h *ExtImageHash) Bits**() int Returns the bit size of the ExtImageHash. - **(h *ExtImageHash) GetHash**() []uint64 Returns the slice of uint64 hash values. - **(h *ExtImageHash) GetKind**() Kind Returns the kind of hash. - **(h *ExtImageHash) ToString**() string Returns the string representation of the extended hash. ``` -------------------------------- ### Go: Pixel Flattening and Grayscale Conversion (Fast) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/transforms_tab=versions Provides fast implementations for flattening pixel data from an image.Image into a float64 slice and converting color images to grayscale. These are useful for preparing image data for further processing. ```go func FlattenPixelsFast64(pixels []float64, x int, y int) []float64 func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) []float64 ``` -------------------------------- ### ExtImageHash Functions (v0.3.0) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Provides extended image hashing functions using AverageHashExtend, DifferenceHashExtend, and PerceptionHashExtend, along with string conversion and distance calculation for `ExtImageHash`. ```APIDOC ## ExtImageHash Functions ### Description This section details the functions for creating and manipulating extended `ExtImageHash` objects, offering more control over hash size and format. ### Methods #### `AverageHashExtend(img image.Image, hashSize int) (*ExtImageHash, error)` - **Description**: Computes the average hash of an image with a specified hash size. - **Type**: Function #### `DifferenceHashExtend(img image.Image, hashSize int) (*ExtImageHash, error)` - **Description**: Computes the difference hash of an image with a specified hash size. - **Type**: Function #### `PerceptionHashExtend(img image.Image, hashSize int) (*ExtImageHash, error)` - **Description**: Computes the perception hash of an image with a specified hash size. - **Type**: Function #### `ExtImageHashFromString(s string) (*ExtImageHash, error)` - **Description**: Creates an `ExtImageHash` from its string representation. - **Type**: Function #### `NewExtImageHash(hash []uint64, kind Kind) *ExtImageHash` - **Description**: Creates a new `ExtImageHash` with the given hash values and kind. - **Type**: Function ### Type: ExtImageHash #### `Distance(other *ExtImageHash) (int, error)` - **Description**: Calculates the Hamming distance between two `ExtImageHash` objects. - **Type**: Method #### `GetHash() []uint64` - **Description**: Returns the hash values of the `ExtImageHash`. - **Type**: Method #### `GetKind() Kind` - **Description**: Returns the kind of the `ExtImageHash`. - **Type**: Method #### `ToString() string` - **Description**: Converts the `ExtImageHash` to its string representation. - **Type**: Method ``` -------------------------------- ### Calculate Median of Pixels Fast64 (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/etcs The MedianOfPixelsFast64 function, introduced in v1.1.0, efficiently calculates the median of float64 pixel values using an optimized quick selection algorithm. This version is designed for performance-critical applications requiring rapid median computations. ```Go func MedianOfPixelsFast64(pixels []float64) float64 { // Optimized implementation for calculating the median using quick selection } ``` -------------------------------- ### Calculate Median of Pixels (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/etcs The MedianOfPixels function computes the median value from a slice of float64 pixel values using the quick selection algorithm. This method is robust against outliers and suitable for image analysis where central tendency is important. ```Go func MedianOfPixels(pixels []float64) float64 { // Implementation details for calculating the median using quick selection } ``` -------------------------------- ### Calculate Median of Pixels in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/etcs The MedianOfPixels function computes the median value from a slice of pixel data (float64) using the quick selection algorithm. It accepts a slice of float64 and returns a float64 representing the median. The quick selection algorithm is efficient for finding medians. ```go func MedianOfPixels(pixels []float64) float64 { // Implementation details using quick selection algorithm... } ``` -------------------------------- ### Extended Perception Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Calculates an extended Perception Hash for a given image with specified width and height. This function is available in v1.1.0 and later versions. It takes an image.Image, width, and height, returning an ExtImageHash pointer and an error. ```Go func ExtPerceptionHash(img image.Image, width, height int) (*ExtImageHash, error) ``` -------------------------------- ### ImageHash String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Converts an ImageHash to its string representation and vice versa. ImageHashFromString is available in v0.1.0+, and ToString is available in v0.1.0+. ```Go func ImageHashFromString(s string) (*ImageHash, error) func (h *ImageHash) ToString() string ``` -------------------------------- ### Go Fast DCT1DFast64 Transformation Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions An optimized version for calculating the 1-dimensional Discrete Cosine Transform (DCT) on float64 slices. It takes a slice of float64 as input and returns the transformed slice, intended for high-performance scenarios within the goimagehash transforms package. ```Go func DCT1DFast64(input []float64) []float64 ``` -------------------------------- ### ImageHash from String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Creates an ImageHash object from its string representation. This function is available in v0.1.0 and later versions. It takes a string and returns an ImageHash pointer and an error. ```Go func ImageHashFromString(s string) (*ImageHash, error) ``` -------------------------------- ### Extended ImageHash String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Converts an ExtImageHash to its string representation and vice versa. ExtImageHashFromString is available in v0.3.0+, and ToString is available in v0.3.0+. ```Go func ExtImageHashFromString(s string) (*ExtImageHash, error) func (h *ExtImageHash) ToString() string ``` -------------------------------- ### Calculate Median of Pixels (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/etcs The MedianOfPixels function computes the median value from a slice of float64 pixel data using the quick selection algorithm. It accepts a slice of float64 and returns a float64 representing the median. This function is part of the goimagehash package. ```go func MedianOfPixels(pixels []float64) float64 ``` -------------------------------- ### Create Average Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Generates an Average Hash for a given image. This function is available in v0.1.0 and later. It takes an image.Image and returns an ImageHash and an error. ```Go func AverageHash(img image.Image) (*ImageHash, error) ``` -------------------------------- ### Pixel Flattening Functions (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/transforms_tab=versions Includes functions to flatten pixel data from a 2D representation to a 1D slice. Supports both fast (float64) and standard (float64) versions, used within the goimagehash transforms package. ```Go func FlattenPixelsFast64(pixels []float64, x int, y int) []float64 func FlattenPixels(pixels [][]float64, x int, y int) []float64 ``` -------------------------------- ### Apply 1D DCT Transformation - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms The DCT1D function computes the unscaled DCT-II transformation on a 1D slice of float64 values. It utilizes an algorithm by Byeong Gi Lee from 1984. This is useful for frequency domain analysis of image data. ```Go func DCT1D(input []float64) []float64 DCT1D function returns result of DCT-II. DCT type II, unscaled. Algorithm by Byeong Gi Lee, 1984. ``` -------------------------------- ### Go: Fast DCT-II Transform (64-bit) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/transforms_tab=versions Implements a fast Discrete Cosine Transform type II (DCT-II) for 1D and 2D float64 slices. These functions are optimized for performance and are suitable for image processing tasks where DCT is applied. ```go func DCT1DFast64(input []float64) []float64 func DCT2DFast64(input *[]float64) []float64 ``` -------------------------------- ### Calculate Median of Pixels (Quickselect) in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/etcs The MedianOfPixels function computes the median value from a slice of float64 pixel data using the quickselect algorithm. This method is efficient for finding the median, providing a robust measure of central tendency for image pixel distributions. It accepts a slice of float64 and returns a float64 median. ```go func MedianOfPixels(pixels []float64) float64 MedianOfPixels function returns a median value of pixels. It uses quick selection algorithm. ``` -------------------------------- ### Extended Image Hash from String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Creates an ExtImageHash object from its string representation. This function is available in v0.3.0 and later versions. It takes a string and returns an ExtImageHash pointer and an error. ```Go func ExtImageHashFromString(s string) (*ExtImageHash, error) ``` -------------------------------- ### Convert RGB image to grayscale array efficiently in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/transforms The Rgb2GrayFast function provides an optimized method for converting an image.Image object (in RGB format) to a 2D slice of float64 representing grayscale values. It takes the color image and a pointer to a float64 slice for storing the results. This fast implementation aims to improve conversion speed. ```Go func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) Rgb2GrayFast function converts RGB to a gray scale array. ``` -------------------------------- ### Add MedianOfPixelsFast64 Function in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/etcs_tab=versions Introduces the MedianOfPixelsFast64 function to the goimagehash package. This function likely provides an optimized method for calculating the median of pixel values, useful for image hashing algorithms. It operates on a slice of float64 representing pixel data. ```go package imagehash // MedianOfPixelsFast64 calculates the median of pixel values efficiently. // It takes a slice of float64 representing pixel data. func MedianOfPixelsFast64(pixels []float64) float64 { // Implementation details would go here return 0.0 } ``` -------------------------------- ### Go: Fast RGB to Grayscale Conversion Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.2/transforms_tab=versions Converts an image.Image to a float64 slice representing grayscale pixel values using a fast algorithm. This function is efficient for real-time image processing tasks. ```go func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) []float64 ``` -------------------------------- ### Extended Average Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Calculates an extended Average Hash for a given image with specified width and height. This function is available in v1.1.0 and later versions. It takes an image.Image, width, and height, returning an ExtImageHash pointer and an error. ```Go func ExtAverageHash(img image.Image, width, height int) (*ExtImageHash, error) ``` -------------------------------- ### Go Fast Rgb2GrayFast Conversion Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions An optimized function to convert a color image (image.Image) into a slice of float64 representing grayscale pixel data. It efficiently processes the image for grayscale conversion within the goimagehash transforms package. ```Go func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) ``` -------------------------------- ### Create Extended Image Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Creates an extended image hash with specified dimensions. This function is available in v1.1.0 and later. It takes an image.Image, width, and height, returning an ExtImageHash and an error. ```Go func ExtAverageHash(img image.Image, width, height int) (*ExtImageHash, error) ``` ```Go func ExtDifferenceHash(img image.Image, width, height int) (*ExtImageHash, error) ``` ```Go func ExtPerceptionHash(img image.Image, width, height int) (*ExtImageHash, error) ``` -------------------------------- ### Go: Standard DCT-II Transform Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/transforms_tab=versions Implements standard Discrete Cosine Transform type II (DCT-II) for 1D and 2D float64 slices. This version may be less optimized than the fast variants but offers a standard implementation. ```go func DCT1D(input []float64) []float64 func DCT2D(input [][]float64, w int, h int) [][]float64 ``` -------------------------------- ### DCT1D Function for Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/transforms Implements the Discrete Cosine Transform (DCT-II) for a 1D float64 slice. This function is designed to mimic Matlab's dct() behavior, with an implementation reference available online. It takes a slice of float64 as input and returns a transformed slice of float64. ```go func DCT1D(input []float64) []float64 { // ... implementation details ... } ``` -------------------------------- ### ImageHash Functions (v0.1.0) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Provides functions for generating ImageHash using AverageHash, DifferenceHash, and PerceptionHash algorithms, along with utilities for string conversion and distance calculation. ```APIDOC ## ImageHash Functions ### Description This section details the functions for creating and manipulating `ImageHash` objects, including hashing algorithms and utility methods. ### Methods #### `AverageHash(img image.Image) (*ImageHash, error)` - **Description**: Computes the average hash of an image. - **Type**: Function #### `DifferenceHash(img image.Image) (*ImageHash, error)` - **Description**: Computes the difference hash of an image. - **Type**: Function #### `PerceptionHash(img image.Image) (*ImageHash, error)` - **Description**: Computes the perception hash of an image. - **Type**: Function #### `ImageHashFromString(s string) (*ImageHash, error)` - **Description**: Creates an `ImageHash` from its string representation. - **Type**: Function #### `NewImageHash(hash uint64, kind Kind) *ImageHash` - **Description**: Creates a new `ImageHash` with the given hash value and kind. - **Type**: Function ### Type: ImageHash #### `Distance(other *ImageHash) (int, error)` - **Description**: Calculates the Hamming distance between two `ImageHash` objects. - **Type**: Method #### `GetHash() uint64` - **Description**: Returns the hash value of the `ImageHash`. - **Type**: Method #### `GetKind() Kind` - **Description**: Returns the kind of the `ImageHash`. - **Type**: Method #### `Set(idx int)` - **Description**: Sets a specific bit in the hash (usage context might be limited). - **Type**: Method #### `ToString() string` - **Description**: Converts the `ImageHash` to its string representation. - **Type**: Method ### Type: Kind Constants representing different hashing algorithms (AHash, DHash, PHash, WHash, Unknown). ``` -------------------------------- ### Go: Fast DCT-2D Transformation Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.0/transforms_tab=versions Implements a fast 2D Discrete Cosine Transform for a slice of float64 slices, representing image data. This function is optimized for speed within the goimagehash transforms package. ```go func DCT2DFast64(input *[]float64) []float64 ``` -------------------------------- ### Calculate Median of Pixels in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.0/etcs The MedianOfPixels function calculates the median value of a slice of float64 representing pixel data using the quick selection algorithm. It takes a slice of float64 as input and returns a single float64 representing the median. ```go func MedianOfPixels(pixels []float64) float64 ``` -------------------------------- ### Go: MedianOfPixelsFast64 Function Signature Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/etcs_tab=versions This snippet shows the function signature for MedianOfPixelsFast64, which calculates the median of pixel values. It takes a slice of float64 and returns a float64. This function is available in v1.1.0 of the goimagehash module. ```go func MedianOfPixelsFast64(pixels []float64) float64 ``` -------------------------------- ### Create Difference Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Generates a Difference Hash for a given image. This function is available in v0.1.0 and later. It takes an image.Image and returns an ImageHash and an error. ```Go func DifferenceHash(img image.Image) (*ImageHash, error) ``` -------------------------------- ### Add MeanOfPixels and MedianOfPixels Functions in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/etcs_tab=versions Adds MeanOfPixels and MedianOfPixels functions to the goimagehash package. These functions are fundamental for image processing and hashing, allowing for the calculation of average and median pixel values respectively. They operate on slices of float64. ```go package imagehash // MeanOfPixels calculates the average of pixel values. // It takes a slice of float64 representing pixel data. func MeanOfPixels(pixels []float64) float64 { // Implementation details would go here return 0.0 } // MedianOfPixels calculates the median of pixel values. // It takes a slice of float64 representing pixel data. func MedianOfPixels(pixels []float64) float64 { // Implementation details would go here return 0.0 } ``` -------------------------------- ### Extended Difference Hash (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Calculates an extended Difference Hash for a given image with specified width and height. This function is available in v1.1.0 and later versions. It takes an image.Image, width, and height, returning an ExtImageHash pointer and an error. ```Go func ExtDifferenceHash(img image.Image, width, height int) (*ExtImageHash, error) ``` -------------------------------- ### Go DCT2D Transformation Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions Performs a 2-dimensional Discrete Cosine Transform (DCT) on a 2D slice of float64 values representing image pixels. It requires the input data, width (w), and height (h) to execute correctly. This function is available in the goimagehash transforms package. ```Go func DCT2D(input [][]float64, w int, h int) [][]float64 ``` -------------------------------- ### Calculate Median of Pixels Fast (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/etcs_tab=versions An optimized version for calculating the median value from a slice of float64 pixel data. Introduced in version v1.1.0 of the goimagehash package, this function aims for improved performance. It takes a slice of float64 and returns the median as a float64. ```go package main import ( "fmt" "github.com/corona10/goimagehash" ) func main() { pixels := []float64{1.0, 2.5, 3.0, 4.5, 5.0, 6.0, 7.5} medianFast := goimagehash.MedianOfPixelsFast64(pixels) fmt.Printf("Fast Median of pixels: %f\n", medianFast) } ``` -------------------------------- ### Perform Fast 2D DCT on float64 array in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/transforms The DCT2DFast64 function computes the 2D Discrete Cosine Transform using the separability property, optimized with static DCT tables for enhanced performance. It takes a pointer to a slice of float64 as input. This fast implementation aims to improve processing speed compared to a standard 2D DCT. ```Go func DCT2DFast64(input *[]float64) DCT2DFast64 function returns a result of DCT2D by using the seperable property. Fast uses static DCT tables for improved performance. ``` -------------------------------- ### Go DCT1D Transformation Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions Implements the 1-dimensional Discrete Cosine Transform (DCT) for float64 slices. It takes a slice of float64 as input and returns a transformed slice. This function is part of the goimagehash transforms package. ```Go func DCT1D(input []float64) []float64 ``` -------------------------------- ### Calculate Median of Pixels Fast (64-bit) in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/etcs_tab=versions Calculates the median value of a slice of float64 pixel values using a potentially faster algorithm optimized for 64-bit operations. This function is part of the goimagehash library. ```Go package imagehash func MedianOfPixelsFast64(pixels []float64) float64 { // Implementation details... } ``` -------------------------------- ### Go Fast FlattenPixelsFast64 Function Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms_tab=versions An optimized function to flatten a 2D representation of pixels (as float64) into a 1D slice. It requires the pixel data, along with the image's width (x) and height (y), to perform the conversion efficiently. This is part of the goimagehash transforms package. ```Go func FlattenPixelsFast64(pixels []float64, x int, y int) []float64 ``` -------------------------------- ### Go: Pixel Flattening and Grayscale Conversion Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/transforms_tab=versions Standard functions for flattening pixel data from a 2D float64 slice and converting color images to grayscale. These functions are part of the core image processing utilities. ```go func FlattenPixels(pixels [][]float64, x int, y int) []float64 func Rgb2Gray(colorImg image.Image) [][]float64 ``` -------------------------------- ### Calculate 1D Discrete Cosine Transform (DCT1D) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/transforms The DCT1D function computes the Discrete Cosine Transform of type II for a 1D input array, mirroring Matlab's dct() implementation. It takes a slice of float64 as input and returns a slice of float64 representing the transformed data. The implementation reference is provided. ```Go func DCT1D(input []float64) []float64 { // Implementation details... } ``` -------------------------------- ### Load Image Hash from Reader (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Loads an ImageHash from an io.Reader. This function is available in v0.1.0 and later. It reads hash data from the reader and returns an ImageHash and an error. ```Go func LoadImageHash(b io.Reader) (*ImageHash, error) ``` -------------------------------- ### Compute 2D DCT - DCT2D Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/transforms Computes the 2D Discrete Cosine Transform (DCT2D) by leveraging its separable property. It takes a 2D float64 array (matrix), its width, and height as input and returns the transformed 2D array. This is useful for image compression and analysis. ```go func DCT2D(input [][]float64, w int, h int) [][]float64 { // Implementation details... return nil } ``` -------------------------------- ### Convert RGB Image to Grayscale Array - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms The Rgb2Gray function converts an image.Image object (typically an RGB image) into a 2D slice of float64 representing its grayscale values. This conversion is a common preprocessing step for many image analysis tasks, including hashing. ```Go func Rgb2Gray(colorImg image.Image) [][]float64 Rgb2Gray function converts RGB to a gray scale array. ``` -------------------------------- ### ImageHash to String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Converts an ImageHash object to its string representation. This function is available in v0.1.0 and later versions. It returns the string representation of the hash. ```Go func (h *ImageHash) ToString() string ``` -------------------------------- ### Apply 2D DCT Transformation - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms The DCT2D function calculates the 2D Discrete Cosine Transform using its separable property. It takes a 2D slice of float64 representing the image data, along with its width and height, and returns the transformed 2D slice. This is a fundamental step in many image compression and hashing techniques. ```Go func DCT2D(input [][]float64, w int, h int) [][]float64 DCT2D function returns a result of DCT2D by using the seperable property. ``` -------------------------------- ### Convert RGB image to grayscale (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/transforms_tab=versions Converts an image.Image (RGB) to a 2D float64 slice representing grayscale values. Optimized versions are available for performance. ```Go func Rgb2GrayFast(colorImg image.Image, pixels *[]float64) ``` ```Go func Rgb2Gray(colorImg image.Image) [][]float64 ``` -------------------------------- ### ImageHash Bits Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Returns the number of bits in an ImageHash. Available in v1.0.0 and later. ```Go func (h *ImageHash) Bits() int ``` -------------------------------- ### ImageHash.ToString - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index The ToString method of the ImageHash type returns a hexadecimal string representation of the image hash. This is useful for displaying or storing the hash value. It takes no arguments and returns a string. ```go func (h *ImageHash) ToString() string { // Implementation details would go here } ``` -------------------------------- ### Kind Enum Definitions - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/index The Kind type is an integer enumeration that describes different types of image hashes. It includes constants for Unknown, AHash (Average Hash), PHash (Perceptual Hash), DHash (Difference Hash), and WHash (Wavelet Hash). ```go type Kind int const ( // Unknown is a enum value of the unknown hash. Unknown Kind = iota // AHash is a enum value of the average hash. AHash //PHash is a enum value of the perceptual hash. PHash // DHash is a enum value of the difference hash. DHash // WHash is a enum value of the wavelet hash. WHash ) ``` -------------------------------- ### Calculate Mean of Pixels in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.2.0/etcs The MeanOfPixels function calculates the average value of a slice of pixel data (float64). It takes a slice of float64 as input and returns a single float64 representing the mean. No external dependencies are required. ```go func MeanOfPixels(pixels []float64) float64 { // Implementation details... } ``` -------------------------------- ### Rgb2Gray Function Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms Converts an RGB image to a grayscale pixel array. ```APIDOC ## Rgb2Gray ### Description Rgb2Gray function converts RGB to a gray scale array. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go func Rgb2Gray(colorImg image.Image) [][]float64 ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go func Rgb2Gray(colorImg image.Image) [][]float64 ``` ### Response #### Success Response (200) - **[][]float64**: A 2D array representing the grayscale image pixels. #### Response Example ```go // Example usage would involve calling the function with an image.Image object. ``` ``` -------------------------------- ### Extended ImageHash Bits Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Returns the number of bits in an ExtImageHash. Available in v1.1.0 and later. ```Go func (h *ExtImageHash) Bits() int ``` -------------------------------- ### Calculate Median of Pixels (Fast64, Quickselect) in Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.1.0/etcs Added in v1.1.0, MedianOfPixelsFast64 offers an optimized median calculation for float64 pixel slices using the quickselect algorithm. Similar to MedianOfPixels, it efficiently determines the central value in pixel data, suitable for performance-critical image processing tasks. The function takes a []float64 and returns a float64. ```go func MedianOfPixelsFast64(pixels []float64) float64 MedianOfPixelsFast64 function returns a median value of pixels. It uses quick selection algorithm. ``` -------------------------------- ### Load Extended Image Hash from Reader (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Loads an ExtImageHash from an io.Reader. This function is available in v1.1.0 and later. It reads hash data from the reader and returns an ExtImageHash and an error. ```Go func LoadExtImageHash(b io.Reader) (*ExtImageHash, error) ``` -------------------------------- ### Extended Image Hash to String Conversion (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/index_tab=versions Converts an ExtImageHash object to its string representation. This function is available in v0.3.0 and later versions. It returns the string representation of the hash. ```Go func (h *ExtImageHash) ToString() string ``` -------------------------------- ### DCT2D Function for Go Image Processing Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/transforms_tab=versions Performs a 2-Dimensional Discrete Cosine Transform (DCT) on a 2D slice of float64 representing image data. It takes the 2D pixel data, width, and height as input and returns the transformed 2D data. Optimized versions are available for faster computation. ```go func DCT2D(input [][]float64, w int, h int) [][]float64 ``` ```go func DCT2DFast64(input *[]float64) []float64 ``` -------------------------------- ### Calculate Mean of Pixels (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/etcs The MeanOfPixels function calculates the arithmetic mean of a slice of float64 pixel values. This is a fundamental operation for image analysis and can be used as a simple feature for image comparison. ```Go func MeanOfPixels(pixels []float64) float64 { // Implementation details for calculating the mean } ``` -------------------------------- ### Extended ImageHash GetHash Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Retrieves the hash values of an ExtImageHash. Available in v0.3.0 and later. ```Go func (h *ExtImageHash) GetHash() []uint64 ``` -------------------------------- ### Calculate Median of Pixels - Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/etcs The MedianOfPixels function computes the median value from a slice of pixel data using the quick selection algorithm. It accepts a slice of float64 and returns a float64. This function is valuable for image processing tasks where outliers might skew the mean. ```Go func MedianOfPixels(pixels []float64) float64 { // Implementation using quick selection algorithm... } ``` -------------------------------- ### DCT1D: Perform 1D Discrete Cosine Transform (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/transforms DCT1D calculates the DCT-II for a slice of float64 values, mimicking Matlab's dct() function. It references an external implementation for details. The function takes a slice of float64 as input and returns a slice of float64. ```Go func DCT1D(input []float64) []float64 { // ... implementation details ... } ``` -------------------------------- ### Convert RGB Image to Grayscale Array - Rgb2Gray Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.3/transforms Converts a standard Go image.Image (in RGB format) into a 2D array of float64 representing the grayscale intensity. This function is essential for many image processing algorithms that require grayscale input. ```go import "image" func Rgb2Gray(colorImg image.Image) [][]float64 { // Implementation details... return nil } ``` -------------------------------- ### Calculate Median of Pixels using Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/etcs The MedianOfPixels function determines the median value from a slice of float64 pixel data using the quick selection algorithm. It accepts a slice of float64 and returns a float64 representing the median. This function is valuable for image analysis when a robust measure of central tendency is needed, less sensitive to outliers than the mean. ```go func MedianOfPixels(pixels []float64) float64 { // Implementation using quick selection algorithm } ``` -------------------------------- ### ImageHash GetHash Method (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0 Retrieves the hash value of an ImageHash. Available in v0.1.0 and later. ```Go func (h *ImageHash) GetHash() uint64 ``` -------------------------------- ### FlattenPixels Function for Go Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/transforms Converts a 2D slice of float64 (representing pixels) into a 1D slice. The function takes the 2D pixel data along with specified x and y coordinates for cropping or selection. It returns a flattened slice of float64. ```go func FlattenPixels(pixels [][]float64, x int, y int) []float64 { // ... implementation details ... } ``` -------------------------------- ### Calculate Median of Pixels (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.3.0/etcs_tab=versions Calculates the median value from a slice of float64 pixel data. This function is part of the goimagehash package and is available from version v0.1.0 onwards. It takes a slice of float64 as input and returns a single float64 representing the median. ```go package main import ( "fmt" "github.com/corona10/goimagehash" ) func main() { pixels := []float64{1.0, 2.5, 3.0, 4.5, 5.0} median := goimagehash.MedianOfPixels(pixels) fmt.Printf("Median of pixels: %f\n", median) } ``` -------------------------------- ### Calculate Mean of Pixels (Go) Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v0.1.0/etcs The MeanOfPixels function calculates the average value of a slice of float64 pixel data. It takes a slice of float64 as input and returns a single float64 representing the mean. This function is part of the goimagehash package. ```go func MeanOfPixels(pixels []float64) float64 ``` -------------------------------- ### DCT2D Function Source: https://pkg.go.dev/github.com/corona10/goimagehash/%40v1.0.1/transforms Calculates the 2D Discrete Cosine Transform (DCT2D) using its separable property. ```APIDOC ## DCT2D ### Description DCT2D function returns a result of DCT2D by using the seperable property. ### Method Not applicable (function) ### Endpoint Not applicable (function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go func DCT2D(input [][]float64, w int, h int) [][]float64 ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```go func DCT2D(input [][]float64, w int, h int) [][]float64 ``` ### Response #### Success Response (200) - **[][]float64**: The result of the 2D DCT transformation. #### Response Example ```go // Example usage would involve calling the function with a 2D float64 slice and dimensions. ``` ```