BinToHex.m
复制代码
1
2
3
4
5
6
7
8
9
10function str=BinToHex(A) str=''; for i=1:8 for j=1:4:8 temp = dec2hex(bin2dec(num2str(A(i,j:j+3)))); str=strcat(str,num2str(temp)); end end end
Perceptual_hash_algorithm
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18function A=Perceptual_hash_algorithm(str) img=imread(str); %转换为灰度图 temp=rgb2gray(img); %缩小到8*8 img2=imresize(temp,[8 8]); %划分灰度等级为64 img2=uint8(double(img2)/4); %求均值 average=mean(mean(img2)); %生成二进制矩阵 img2(img2<average) = 0; img2(img2>=average) = 1; A=img2; %将二进制转换为16进制,指纹 Str=BinToHex(A) end
hash.m
复制代码
1
2
3
4
5
6clear all; clc; E=Perceptual_hash_algorithm('G:\壁纸\高达UC\gundam_uc-026.jpg'); F=Perceptual_hash_algorithm('G:\壁纸\高达UC\26_A.jpg'); G=xor(E,F); a=sum(G(:)==1)
最后
以上就是淡定大炮最近收集整理的关于Matlab 实现感知哈希法的全部内容,更多相关Matlab内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复