Content_Feature.m
function A=Content_Feature(str) i=imread(str); g=rgb2gray(i); A = imresize(g,[50 50]); imshow(A); Min=min(min(A)); Max=max(max(A)); result=-1; tag=Min; for i=Min:Max temp=DaJin(A,i); if result<temp result=temp; tag=i; end end for j=1:50 for k=1:50 if A(j,k)>tag A(j,k)=1; else A(j,k)=0; end end end end
DaJin.m
function result=DaJin(A,threshold) count1=0; count2=0; B=[]; C=[]; for i=1:50 for j=1:50 if (A(i,j)>threshold) count1=count1+1; B(count1)=A(i,j); else count2=count2+1; C(count2)=A(i,j); end end end %求均值 threshold; u1=mean(B); u2=mean(C); w1=size(B,2)/2500; w2=size(C,2)/2500; result=w1*w2*((u1-u2)^2); end
main.m
clear all; clc; E=Content_Feature('gundam_uc-026.jpg'); F=Content_Feature('9.jpg'); G=xor(E,F); a=sum(G(:)==1)