forked from IvanPizhenko/blockhash
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathblockhash.h
65 lines (55 loc) · 1.92 KB
/
blockhash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Perceptual image hash calculation library based on algorithm descibed in
* Block Mean Value Based Image Perceptual Hashing by Bian Yang, Fan Gu and Xiamu Niu
*
* Copyright 2014-2015 Commons Machinery http://commonsmachinery.se/
* Distributed under an MIT license, please see LICENSE in the top dir.
*/
#ifndef __BLOCKHASH_BLOCKHASH_H__
#define __BLOCKHASH_BLOCKHASH_H__
#ifdef __cplusplus
extern "C" {
#endif
/** Convert array of bits to hexadecimal string representation.
* Hash length should be a multiple of 4.
*
* Returns: null-terminated hexadecimal string hash on succes, NULL on failure.
*/
char* bits_to_hexhash(int *bits, int nbits);
/** Calculate perceptual hash for an RGBA image using quick method.
*
* Quick method uses rounded block sizes and is less accurate in case image
* width and height are not divisible by the number of bits.
*
* Parameters:
*
* bits - number of blocks to divide the image by horizontally and vertically.
* data - RGBA image data.
* width - image width.
* height - image height.
* hash - the resulting hash will be allocated and stored in the given array as bits.
*
* Returns: 0 on success, -1 on failure.
*/
int blockhash_quick(int bits, unsigned char *data, int width, int height, int **hash);
/** Calculate perceptual hash for an RGBA image using precise method.
*
* Precise method puts weighted pixel values to blocks according to pixel
* area falling within a given block and provides more accurate results
* in case width and height are not divisible by the number of bits.
*
* Parameters:
*
* bits - number of blocks to divide the image by horizontally and vertically.
* data - RGBA image data.
* width - image width.
* height - image height.
* hash - the resulting hash will be allocated and stored in the given array as bits.
*
* Returns: 0 on success, -1 on failure.
*/
int blockhash(int bits, unsigned char *data, int width, int height, int **hash);
#ifdef __cplusplus
}
#endif
#endif