资源简介
用POCS方法对图像进行超分辨率重构,matlab源码,有解释
代码片段和文件信息
% 位移、角度估计后利用pocs法求超精度图像
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
s{1}=double(imread(‘tu1.jpg‘));
[rowcolum]=size(s{1});
r2=1:2*row;c2=1:2*colum;
r2=r2/2;c2=c2/2;c2=c2‘;
s{1}=interp2(s{1}r2c2‘cubic‘)
img1=uint8(s{1});
for k=2:4
s{2}=double(imread(strcat(‘tu‘num2str(k)‘.jpg‘)));
[rowcolum]=size(s{2});
r2=1:2*row;c2=1:2*colum;
r2=r2/2;c2=c2/2;c2=c2‘;
s{2}=interp2(s{2}r2c2‘cubic‘);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%估计角度
img2=uint8(s{2});
[im1 des1 loc1] = sift(img1);
[im2 des2 loc2] = sift(img2);
distRatio = 0.75;
des2t = des2‘;
for i = 1:size(des11)
dotprods = des1(i:) * des2t;
[valsindx] = sort(acos(dotprods));
if (vals(1) < 0.15) && (vals(1) < distRatio * vals(2))
match1(i) = indx(1);
else
match1(i) = 0;
end
end
cols1 = size(im12);
j = 1;
for i = 1: size(des11)
if (match1(i) > 0)
%line([loc1(i2) loc2(match1(i)2)+cols1] ...
%[loc1(i1) loc2(match1(i)1)] ‘Color‘ ‘r‘);
point1(j:) = loc1(i:);
point2(j:) = loc2(match1(i):);
j = j + 1;
end
end
num = sum(match1 > 0);
if num <= 1
%fprintf(‘too few matches found.\n‘ num);
return;
end
distpoint = point1 - point2;
for i = 1 : size(point11)
if distpoint(i4) >= 3.14159
distpoint(i4) = distpoint(i4) - 3.14159 * 2;
else
if distpoint(i4) <= -3.14159
distpoint(i4) = distpoint(i4) + 3.14159 * 2;
end
end
end
rotation = 0;
count = 0;
for i = 2 : size(point11)
distdistpoint = distpoint(i4) - distpoint(i-14);
if abs(distdistpoint) > 0.5*abs(sum(abs(distpoint(:4)))/size(distpoint1))
continue;
end
if abs(distpoint(i4)) > 1.5*abs(sum(abs(distpoint(:4)))/size(distpoint1))
continue;
end
rotation = rotation + distpoint(i4);
count = count + 1;
end
if rotation == 0
rotation = sum(distpoint(:4))/size(distpoint1) * 180 / 3.14159;
else
rotation = rotation / count * 180 / 3.14159;
end
phi_rad(1)=0;phi_rad(2)=rotation;
%角度补偿
img2 = imrotate(img2-rotation‘bicubic‘‘crop‘);
s{2}=double(img2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 位移估计
delta_est = estimate_shift(s8);
s{2}=double(imread(strcat(‘tu‘num2str(k)‘.jpg‘)));
[rowcolum]=size(s{2});
r2=1:2*row;c2=1:2*colum;
r2=r2/2;c2=c2/2;c2=c2‘;
s{2}=interp2(s{2}r2c2‘cubic‘);
%求img2补偿后的坐标
factor=1;
ss = size(s{1});
center = (ss+1)/2;
for i=1:2
r{i} = [1:factor:factor*ss(1)]‘*ones(1ss(2)); % create matrix with row indices
c{i} = ones(ss(1)1)*[1:factor:factor*ss(2)]; % create matrix with column indices
r{i} = r{i}-factor*center(1); % shift rows to center around 0
c{i} = c{i}-factor*center(2); % shift columns to center around 0
coord{i} = [c{i}(:) r{i}(:)]*[cos(phi_rad(i)) sin(phi_rad(i)); -sin(phi_rad(i)) c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4427 2006-12-05 20:39 rotation_estimate.m
文件 4647 2006-12-09 16:31 pocs2.m
文件 2533 2006-12-07 17:07 pocs4.m
文件 3879 2006-12-12 14:09 result.m
文件 1730 2006-12-09 16:39 rotation.m
----------- --------- ---------- ----- ----
17434 6
- 上一篇:gabor滤波器的matlab源代码
- 下一篇:小波进行边缘检测
评论
共有 条评论