#include <GDIPlus.au3>
#include <ScreenCapture.au3>
_GDIPlus_Startup()
$file_1 = '11.jpg'
$file_2 = '12.jpg'
$result = CC($file_1, $file_2)
MsgBox(0, 'Результат', 'Изображения похожи на: ' & Round($result * 100, 5) & '%')
_GDIPlus_Shutdown()
Func CC($file_1, $file_2)
Local $file_out_1 = _convert_to_bmp($file_1, 'out_1.bmp')
Local $file_out_2 = _convert_to_bmp($file_2, 'out_2.bmp')
Local $digest_1 = ph_image_digest($file_out_1)
Local $digest_2 = ph_image_digest($file_out_2)
Local $result = ph_crosscorr($digest_1, $digest_2, 0.85)
Return SetError(@error, @extended, $result)
EndFunc ;==>CC
Func _convert_to_bmp($file, $file_out = 'out.bmp')
Local $hImage = _GDIPlus_ImageLoadFromFile($file)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0xFFFFFFFF)
_ScreenCapture_SaveImage($file_out, $hBitmap)
_GDIPlus_ImageDispose($hImage)
Return $file_out
EndFunc ;==>_convert_to_bmp
Func ph_image_digest($file, $sigma = 1.0, $gamma = 1.0, $N = 180)
;~ int ph_image_digest(const char *file, double sigma, double gamma, Digest &digest,int N=180);
;~ /*! /brief Digest info
;~ */
;~ typedef unsigned char uint8_t;
;~ typedef struct ph_digest {
;~ char *id; //hash id
;~ uint8_t *coeffs; //the head of the digest integer coefficient array
;~ int size; //the size of the coeff array
;~ } Digest;
Local $Digest = DllStructCreate('CHAR id; UINT coeffs; INT size')
Local $aResult = DllCall("pHash.dll", "int:cdecl", "ph_image_digest", 'str', $file, 'double', $sigma, 'double', $gamma, 'STRUCT*', $Digest, 'int', $N)
If @error Then Return SetError(@error, @extended, "")
Return $Digest
EndFunc ;==>ph_image_digest
Func ph_crosscorr($DigestX, $DigestY, $threshold = 0.9)
;~ To compare two radial hashes, a peak of cross correlation is determined between two hashes:
;~ The peak of cross correlation between the two vectors is returned in the pcc parameter.
;~ int ph_crosscorr(Digest &x, Digest &y, double &pcc, double threshold=0.90);
;~ pcc = max;
;~ if (pcc > threshold) ;pcc > threshold
;~ result = 1;
Local $aResult = DllCall("pHash.dll", "int:cdecl", "ph_crosscorr", 'STRUCT*', $DigestX, 'STRUCT*', $DigestY, 'double*', 0, 'double', $threshold)
If @error Then Return SetError(@error, @extended, "")
Return SetError(0, $aResult[0] = 1, $aResult[3])
EndFunc ;==>ph_crosscorr