Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
---
GitHub release

0.9.8
---
Extend pHash interface with ph_mh_imagehash_from_buffer

0.9.7
---
JNI code cleanup
Expand Down
2 changes: 1 addition & 1 deletion libpHash.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: pHash
Version: 0.9.7
Version: 0.9.8
Release: 1%{?dist}
Summary: pHash, the open source perceptual hashing library

Expand Down
10 changes: 8 additions & 2 deletions src/pHash.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,6 @@ uint8_t *ph_mh_imagehash(const char *filename, int &N, float alpha, float lvl) {
if (filename == NULL) {
return NULL;
}
uint8_t *hash = (unsigned char *)malloc(72 * sizeof(uint8_t));
N = 72;

CImg<uint8_t> src(filename);
CImg<uint8_t> img;
Expand All @@ -635,6 +633,14 @@ uint8_t *ph_mh_imagehash(const char *filename, int &N, float alpha, float lvl) {
}
src.clear();

return ph_mh_imagehash_from_buffer(img, N, alpha, lvl);
}

uint8_t *ph_mh_imagehash_from_buffer(CImg<uint8_t> &img, int &N, float alpha,
float lvl) {
uint8_t *hash = (unsigned char *)malloc(72 * sizeof(uint8_t));
N = 72;

CImg<float> *pkernel = GetMHKernel(alpha, lvl);
CImg<float> fresp = img.get_correlate(*pkernel);
img.clear();
Expand Down
9 changes: 9 additions & 0 deletions src/pHash.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ int ph_hamming_distance(const ulong64 hash1,const ulong64 hash2);
**/
uint8_t* ph_mh_imagehash(const char *filename, int &N, float alpha=2.0f, float lvl = 1.0f);

/** /brief create MH image hash from image buffer
* /param img - image buffer
* /param N - (out) int value for length of image hash returned
* /param alpha - int scale factor for marr wavelet (default=2)
* /param lvl - int level of scale factor (default = 1)
* /return uint8_t array
**/
uint8_t* ph_mh_imagehash_from_buffer(CImg<uint8_t> &img, int &N, float alpha=2.0f, float lvl = 1.0f);

/** /brief count number bits set in given byte
* /param val - uint8_t byte value
* /return int value for number of bits set
Expand Down