📄 image_division.m
字号:
%--------------------------------------------------------------------------
% filename: image_division
% function: 图像重复性检测
% data : 2005.11.3
%--------------------------------------------------------------------------
function image_division()
I1=imread('picture\200\1\SCN0033A.jpg');
I2=imread('picture\200\2\SCN0069A.jpg');
I3=imread('picture\200\1\SCN0039A.jpg');
%I4=imread('picture\200\1\SCN0041A.jpg');
%I5=imread('picture\200\1\SCN0043A.jpg');
I1=double(I1);
I2=double(I2);
I3=double(I3);
%I4=double(I4);
%I5=double(I5);
% 取大于200的像素
I1_index=find((I1>200)|(I1<40));
I2_index=find((I2>200)|(I2<40));
I3_index=find((I3>200)|(I3<40));
%I4_index=find(I4>200);
%I5_index=find(I5>200);
%像素值大于200的设为空
I1(I1_index)=[];
I2(I2_index)=[];
I3(I3_index)=[];
%I4(I4_index)=[];
%I5(I5_index)=[];
para=input('请输入量化区间:');
disp(para);
% 将图像量化为j值图像
j=256/para;
I1=fix(I1/j);
I2=fix(I2/j);
I3=fix(I3/j);
%I4=fix(I4/j);
%I5=fix(I5/j);
% 统计各区间的像素的个数
for i=1:para
a(i)=length(find(I1==i-1));
b(i)=length(find(I2==i-1));
c(i)=length(find(I3==i-1));
%d(i)=length(find(I4==i-1));
%e(i)=length(find(I5==i-1));
end
a=a/sum(a);
b=b/sum(b);
c=c/sum(c);
%d=d/sum(d);
%e=e/sum(e);
subplot(5,1,1),bar(a);
subplot(5,1,2),bar(b);
subplot(5,1,3),bar(c);
%subplot(5,1,4),bar(d);
%subplot(5,1,5),bar(e);
sub(a,b);
sub(a,c);
%sub(a,d);
%sub(a,e);
sub(b,c);
%sub(b,d);
%sub(b,e);
%sub(c,d);
%sub(c,e);
%sub(d,e);
return
%************************************************************************
% SUB 求两个特征向量的相关系数
%************************************************************************
function xx=sub(s1,s2)
org=s1; % 量化后的两个图像
obj=s2;
n_org_num=length(s1); % 图像像素数目
org_jun=sum(org)/n_org_num;
obj_jun=sum(obj)/n_org_num;
a=org-org_jun;
b=obj-obj_jun;
c=sum(a.*b); % 计算分子
d1=sum(a.*a);d1=d1^0.5;
d2=sum(b.*b);d2=d2^0.5;
d=d1*d2; % % 计算分母
% display('相关值为:');
corr_result=c/d;
xx=corr_result
return
%************************************************************************** %end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -