资源简介
利用matlab实现基于颜色的内容提取,对100副图片进行分析,找出相互配对的图形

代码片段和文件信息
clc
clear
% tic
%=====================================================================
%参数初始化
q=0;%0,不量化,非0时,将数值量化为16的整数倍值
rbnum=16;%指定分块个数
cbnum=16;
distancetype=0;%0:绝对值的和 1:欧几里德距离,
histtype=1;%histtype:直方图(0)与累积直方图(1)
%---------------
imagetype=‘bmp‘;% 图片类型
imagesum=100;%要检索的图片库中图片的数目
imageadress=‘F:\张霖\多媒体\大作业要求\颜色作业图库\‘;
%=====================================================================
if q==0
len=256;
else
len=16;
end
Lhist=zeros(imagesumrbnumcbnumlen);
for number=1:imagesum
I=imread([imageadressnum2str(number)‘.‘imagetype]);
[mn]=size(I(::1));
L=rgb2gray(I);
if q~=0
L=floor(double(L)*len/256);
end
for i=1:rbnum
for j=1:cbnum
rs=floor((i-1)*m/rbnum+1);%获得子块行位置向量的起止
re=floor(i*m/rbnum);
cs=floor((j-1)*n/cbnum+1);%获得子块列位置向量的起止
ce=floor(j*n/cbnum);
LS=L(rs:recs:ce);
sm=(re-rs+1);
sn=(ce-cs+1);
Lhist(numberij:)=hist(reshape(LS1sm*sn)0:len-1)/(sm*sn);%计算直方图
end
end
end
if histtype==1
for i=2:len
Lhist(:::i)= Lhist(:::i)+ Lhist(:::i-1);
end
end
%toc
%=====================================================================
%读入待检索的图像
reply = input(‘Do you want to search? Y/N [Y]: ‘ ‘s‘);
while reply == ‘Y‘
searchnum = input(‘Which one do you want to search? (1~100) [1]: ‘);
if isempty(searchnum)
searchnum = 1;
end
tic
d=zeros(1001);
for k=1:imagesum
dd=zeros(rbnumcbnum);
for i=1:rbnum
for j=1:cbnum
if distancetype==0
dd(ij)=sum(abs(Lhist(searchnumij:)-Lhist(kij:)));
else
dd(ij)=sqrt(sum(abs(Lhist(searchnumij:)-Lhist(kij:)).^2));
end
end
end
d(k)=sum(sum(dd.^2))/(rbnum*cbnum);
end
[imagesortdindex]=sort(d);
%======================================================================
%显示检索结果
rows=2;
cols=3;
figure
subplot(rowscols1);
J=imread([imageadressnum2str(searchnum)‘.‘imagetype]);
imshow(rgb2gray(J));
title(‘待检索图象灰度图‘);
%按照相似度从小到大显示图像
for i=1:rows*cols-1%只显示前rows*cols-1个距离最小的图片
J=imread([imageadressnum2str(dindex(i))‘.‘imagetype]);
%J=imread([‘C:\imagesearches\imagedatabase1\‘image]);
subplot(rowscolsi+1)imshow(J);
title([‘No.‘num2str(dindex(i))‘d=‘num2str(imagesort(i))]);
end
% toc
reply = input(‘Do you want to search? Y/N [Y]: ‘ ‘s‘);
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4081 2009-06-15 11:27 sim_main1.m
文件 2855 2009-06-23 09:32 sim_main.m
----------- --------- ---------- ----- ----
6936 2
相关资源
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论