信号处理(三)Image restoration 图像修复

Demand

Consider an image, whose lines have been shifted by a few pixels. The image has been presented below :
在这里插入图片描述
Download to your working directory the file containing the original image: fichier2.bmp.

You can read it with “imread” MATLAB function and display with “image” function:

clear B; 
B=imread('fichier2.bmp','bmp'); 
B=255*B; 
image(B); 
colormap(GRAY);

You must correct the offsets of the image lines (think xcorr function).

The current row of pixels and the next row are cross-correlated. The point with the largest correlation coefficient corresponds to the translation distance of this row relative to the previous row. If there is no translation, the difference between one line of the image and the next line should not be large.

B=imread('fichier2.bmp','bmp');
B=255*B;
image(B);
colormap(gray);
B_new=zeros(size(B));
B_new(1,:)=B(1,:);
j_sum=0;
for i=1:2054
    B1=B(i,:);
    B2=B(i+1,:);
    [a,b]=xcorr(B1,B2,'coeff');
    [m,j]=max(a);
    j=j-3072;
    j_sum=j_sum+j;
    if(j_sum>0)
        B2_2=[ones(1,j_sum)*255,B2(1:3072-j_sum)];
    elseif(j_sum<0)
        B2_2=[B2(-j_sum+1:3072),ones(1,-j_sum)*255];
    elseif(j_sum==0)
        B2_2=B2;
    end
    B_new(i+1,:)=B2_2;
end
image(B_new);
colormap(gray);

Repair results

在这里插入图片描述
Because some pixels are moved out of the image frame, the restored image is incomplete.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值