码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab 图像搜索

时间:2017-05-03 22:51:57      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:matlab   rgb2gray   sub   use   ble   figure   sort   ima   clear   

clc;

clear;

B=[];

for i=31:140

picname=[‘/Users/xuhonghui/Desktop/imageface/‘,num2str(i),‘.jpg‘];

II=imread(picname);

p=imresize(II,[100,100]);

n=rgb2gray(p);

A=double(n(:));

B=[B,A];

end

[U,D,V]=svd(B);

k=2000;

U1=U(:,1:k);

B1=U1‘*B;

for search=1:7

C=imread([‘/Users/xuhonghui/Desktop/searchimageface/‘,num2str(search),‘.jpg‘]);

C1=imresize(C,[100,100]);

n1=rgb2gray(C1);

C2=double(n1(:));

C3=U1‘*C2;

%B2=sign(B1);

%C4=sign(C3);

D=[];

for j=1:110

    temp=abs(norm(B1(:,j))-norm(C3));

    D=[temp,D];

end

%E=sum(D,2);

[y,I]=sort(D);

Y1=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(1)+30),‘.jpg‘]);

Y2=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(2)+30),‘.jpg‘]);

Y3=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(3)+30),‘.jpg‘]);

Y4=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(4)+30),‘.jpg‘]);

Y5=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(5)+30),‘.jpg‘]);

Y6=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(6)+30),‘.jpg‘]);

Y7=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(7)+30),‘.jpg‘]);

Y8=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(8)+30),‘.jpg‘]);

Y9=imread([‘/Users/xuhonghui/Desktop/imageface/‘,num2str(I(9)+30),‘.jpg‘]);

figure;

subplot(4,3,1),imshow(C);

subplot(4,3,4),imshow(Y1);

subplot(4,3,5),imshow(Y2);

subplot(4,3,6),imshow(Y3);

subplot(4,3,7),imshow(Y4);

subplot(4,3,8),imshow(Y5);

subplot(4,3,9),imshow(Y6);

subplot(4,3,10),imshow(Y7);

subplot(4,3,11),imshow(Y8);

subplot(4,3,12),imshow(Y9);

end 

 

Matlab 图像搜索

标签:matlab   rgb2gray   sub   use   ble   figure   sort   ima   clear   

原文地址:http://www.cnblogs.com/XuHonghui/p/6804333.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!