⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phash.h

📁 pHash is an implementation of various perceptual hashing algorithms. A perceptual hash is a fingerpr
💻 H
字号:
/*    pHash, the open source perceptual hash library    Copyright (C) 2008 Aetilius, Inc.    All rights reserved.    This program is free software: you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation, either version 3 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program.  If not, see <http://www.gnu.org/licenses/>.    Evan Klinger - eklinger@phash.org    David Starkweather - dstarkweather@phash.org*/#ifndef _PHASH_H#define _PHASH_H#include <limits.h>#include <math.h>#include "CImg.h"using namespace cimg_library;using namespace std;#define SQRT_TWO 1.4142135623730950488016887242097#define ROUNDING_FACTOR(x) (((x) >= 0) ? 0.5 : -0.5) #if defined( _MSC_VER) || defined(_BORLANDC_)typedef unsigned _uint64 ulong64;typedef signed _int64 long64;#elsetypedef unsigned long long ulong64;typedef signed long long long64;#endiftypedef unsigned char uint8_t;/*! /brief Radon Projection info */typedef struct ph_projections {    CImg<uint8_t> *R;           //contains projections of image of angled lines through center    int *nb_pix_perline;        //the head of int array denoting the number of pixels of each line    int size;                   //the size of nb_pix_perline}Projections;/*! /brief feature vector info */typedef struct ph_feature_vector {    double *features;           //the head of the feature array of double's    int size;                   //the size of the feature array}Features;/*! /brief Digest info */typedef struct ph_digest {    uint8_t *coeffs;            //the head of the digest integer coefficient array    int size;                   //the size of the coeff array} Digest;/*! /brief copyright information */const char* ph_about();/*! /brief radon function *  Find radon projections of N lines running through the image center for lines angled 0 *  to 180 degrees from horizontal. *  /param img - CImg src image *  /param  N  - int number of angled lines to consider. *  /param  projs - (out) Projections struct  *  /return int value - less than 0 for error */int ph_radon_projections(const CImg<uint8_t> &img,int N,Projections &projs);/*! /brief feature vector *         compute the feature vector from a radon projection map. *  /param  projs - Projections struct *  /param  fv    - (out) Features struct *  /return int value - less than 0 for error*/int ph_feature_vector(const Projections &projs,Features &fv);/*! /brief dct  *  Compute the dct of a given vector *  /param R - vector of input series *  /param D - (out) the dct of R *  /return  int value - less than 0 for error*/int ph_dct(const Features &fv, Digest &digest);/*! /brief cross correlation for 2 series *  Compute the cross correlation of two series vectors *  /param x - Digest struct *  /param y - Digest struct *  /param pcc - double value the peak of cross correlation *  /param threshold - double value for the threshold value for which 2 images *                     are considered the same or different. *  /return - int value - 1 (true) for same, 0 (false) for different, < 0 for error */int ph_crosscorr(const Digest &x,const Digest &y,double &pcc, double threshold = 0.90);/*! /brief image digest *  Compute the image digest for an image given the input image *  /param img - CImg object representing an input image *  /param sigma - double value for the deviation for a gaussian filter function  *  /param gamma - double value for gamma correction on the input image *  /param digest - (out) Digest struct *  /param N      - int value for the number of angles to consider.  *  /return       - less than 0 for error */int ph_image_digest(const CImg<uint8_t> &img,double sigma, double gamma,Digest &digest,int N=180);/*! /brief image digest *  Compute the image digest given the file name. *  /param file - string value for file name of input image. *  /param sigma - double value for the deviation for gaussian filter *  /param gamma - double value for gamma correction on the input image. *  /param digest - Digest struct *  /param N      - int value for number of angles to consider */int ph_image_digest(const char *file, double sigma, double gamma, Digest &digest,int N=180);/*! /brief compare 2 images *  /param imA - CImg object of first image  *  /param imB - CImg object of second image *  /param pcc   - (out) double value for peak of cross correlation *  /param sigma - double value for the deviation of gaussian filter *  /param gamma - double value for gamma correction of images *  /param N     - int number for the number of angles of radon projections *  /param theshold - double value for the threshold *  /return int 0 (false) for different images, 1 (true) for same image, less than 0 for error */int ph_compare_images(const CImg<uint8_t> &imA,const CImg<uint8_t> &imB,double &pcc, double sigma = 3.5, double gamma = 1.0,int N=180,double threshold=0.90);/*! /brief compare 2 images *  Compare 2 images given the file names *  /param file1 - char string of first image file *  /param file2 - char string of second image file *  /param pcc   - (out) double value for peak of cross correlation *  /param sigma - double value for deviation of gaussian filter *  /param gamma - double value for gamma correction of images *  /param N     - int number for number of angles *  /return int 0 (false) for different image, 1 (true) for same images, less than 0 for error */int ph_compare_images(const char *file1, const char *file2,double &pcc, double sigma = 3.5, double gamma=1.0, int N=180,double threshold=0.90);/*! /brief return dct matrix, C *  Return DCT matrix of sqare size, N *  /param N - int denoting the size of the square matrix to create. *  /return CImg<double> size NxN containing the dct matrix */CImg<float>* ph_dct_matrix(const int N);/*! /brief compute dct robust image hash *  /param file string variable for name of file *  /param hash of type ulong64 (must be 64-bit variable) *  /return int value - -1 for failure, 1 for success */int ph_dct_imagehash(const char* file,ulong64 &hash);/* ! /brief hamming distance *   Compute the hamming distance between two 64-bit data types *   /param hash1 of type ulong64 denoting an image hash *   /param hash2 of type ulong64 denoting an image hash *   /return int value for the hamming distance, -1 for error *//* ! /brief dct video robust hash *   Compute video hash based on the dct of normalized video 32x32x64 cube *   /param file name of file *   /param hash ulong64 value for hash value *   /return int value - less than 0 for error */int ph_dct_videohash(const char* file,ulong64 &hash);int ph_hamming_distance(const ulong64 hash1,const ulong64 hash2);int ph_rash_videodigest(const char* file,CImg<uint8_t> *p_videodigest);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -