![](http://www.weebly.com/weebly/images/file_icons/gz.png)
21.zip | |
File Size: | 727 kb |
File Type: | zip |
close all
clear all
clc
D1= 'C:\Data\March15\21\';
D2= 'C:\Data\March15\21\db\';
D = 'C:\Data\March15\21\test\';
B='.jpg';
for i=1:1:1
for j=1:1:1
C=num2str(i)
E=num2str(j)
F='_';
filename=strcat(D,C,F,E,B);
I=imread(filename);
[m,n,z]=size(I);% size
figure()
imshow(I)
drawnow
I = imresize(I, [220 110]);
a=input('Insert person information: ')
filename1=strcat(D1,C,F,E,B);
imwrite(I,filename1,'comment',a);
filename1=strcat(D2,C,F,E,B);
imwrite(I,filename1,'comment',a);
end
end
clear all
clc
D1= 'C:\Data\March15\21\';
D2= 'C:\Data\March15\21\db\';
D = 'C:\Data\March15\21\test\';
B='.jpg';
for i=1:1:1
for j=1:1:1
C=num2str(i)
E=num2str(j)
F='_';
filename=strcat(D,C,F,E,B);
I=imread(filename);
[m,n,z]=size(I);% size
figure()
imshow(I)
drawnow
I = imresize(I, [220 110]);
a=input('Insert person information: ')
filename1=strcat(D1,C,F,E,B);
imwrite(I,filename1,'comment',a);
filename1=strcat(D2,C,F,E,B);
imwrite(I,filename1,'comment',a);
end
end
![](http://www.weebly.com/weebly/images/file_icons/gz.png)
data.zip | |
File Size: | 89 kb |
File Type: | zip |
![](http://www.weebly.com/weebly/images/file_icons/gz.png)
images.zip | |
File Size: | 69 kb |
File Type: | zip |
![](http://www.weebly.com/weebly/images/file_icons/gz.png)
testrrr.zip | |
File Size: | 41 kb |
File Type: | zip |
clc
close all
clear all
I1=im2double(imread('C:\Data\February14\25\img\1.jpg'));
I2=im2double(imread('C:\Data\February14\25\img\2.jpg'));
% Get the Key Points
Options.upright=true;
Options.tresh=0.0001;
Ipts1=OpenSurf(I1,Options);
Ipts2=OpenSurf(I2,Options);
% Put the landmark descriptors in a matrix
D1 = reshape([Ipts1.descriptor],64,[]);
D2 = reshape([Ipts2.descriptor],64,[]);
% Find the best matches
err=zeros(1,length(Ipts1));
cor1=1:length(Ipts1);
cor2=zeros(1,length(Ipts1));
for i=1:length(Ipts1),
distance=sum((D2-repmat(D1(:,i),[1 length(Ipts2)])).^2,1);
[err(i),cor2(i)]=min(distance);
end
% Sort matches on vector distance
[err, ind]=sort(err);
cor1=cor1(ind);
cor2=cor2(ind);
% Make vectors with the coordinates of the best matches
Pos1=[[Ipts1(cor1).y]',[Ipts1(cor1).x]'];
Pos2=[[Ipts2(cor2).y]',[Ipts2(cor2).x]'];
Pos1=Pos1(1:30,:);
Pos2=Pos2(1:30,:);
% Show both images
I = zeros([size(I1,1) size(I1,2)*2 size(I1,3)]);
I(:,1:size(I1,2),:)=I1; I(:,size(I1,2)+1:size(I1,2)+size(I2,2),:)=I2;
figure, imshow(I); hold on;
% Show the best matches
plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','-');
plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','o');
% Calculate affine matrix
Pos1(:,3)=1; Pos2(:,3)=1;
M=Pos1'/Pos2';
% Add subfunctions to Matlab Search path
functionname='OpenSurf.m';
functiondir=which(functionname);
functiondir=functiondir(1:end-length(functionname));
addpath([functiondir '/WarpFunctions'])
% Warp the image
I1_warped=affine_warp(I1,M,'bicubic');
% Show the result
figure,
subplot(1,3,1), imshow(I1);title('Figure 1');
subplot(1,3,2), imshow(I2);title('Figure 2');
subplot(1,3,3), imshow(I1_warped);title('Warped Figure 1');
close all
clear all
I1=im2double(imread('C:\Data\February14\25\img\1.jpg'));
I2=im2double(imread('C:\Data\February14\25\img\2.jpg'));
% Get the Key Points
Options.upright=true;
Options.tresh=0.0001;
Ipts1=OpenSurf(I1,Options);
Ipts2=OpenSurf(I2,Options);
% Put the landmark descriptors in a matrix
D1 = reshape([Ipts1.descriptor],64,[]);
D2 = reshape([Ipts2.descriptor],64,[]);
% Find the best matches
err=zeros(1,length(Ipts1));
cor1=1:length(Ipts1);
cor2=zeros(1,length(Ipts1));
for i=1:length(Ipts1),
distance=sum((D2-repmat(D1(:,i),[1 length(Ipts2)])).^2,1);
[err(i),cor2(i)]=min(distance);
end
% Sort matches on vector distance
[err, ind]=sort(err);
cor1=cor1(ind);
cor2=cor2(ind);
% Make vectors with the coordinates of the best matches
Pos1=[[Ipts1(cor1).y]',[Ipts1(cor1).x]'];
Pos2=[[Ipts2(cor2).y]',[Ipts2(cor2).x]'];
Pos1=Pos1(1:30,:);
Pos2=Pos2(1:30,:);
% Show both images
I = zeros([size(I1,1) size(I1,2)*2 size(I1,3)]);
I(:,1:size(I1,2),:)=I1; I(:,size(I1,2)+1:size(I1,2)+size(I2,2),:)=I2;
figure, imshow(I); hold on;
% Show the best matches
plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','-');
plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','o');
% Calculate affine matrix
Pos1(:,3)=1; Pos2(:,3)=1;
M=Pos1'/Pos2';
% Add subfunctions to Matlab Search path
functionname='OpenSurf.m';
functiondir=which(functionname);
functiondir=functiondir(1:end-length(functionname));
addpath([functiondir '/WarpFunctions'])
% Warp the image
I1_warped=affine_warp(I1,M,'bicubic');
% Show the result
figure,
subplot(1,3,1), imshow(I1);title('Figure 1');
subplot(1,3,2), imshow(I2);title('Figure 2');
subplot(1,3,3), imshow(I1_warped);title('Warped Figure 1');