資源簡介
基于距離向量矩陣,對有有污點的圖像進行修復。

代碼片段和文件信息
clear?all
close?all
I=imread(‘1.jpg‘);
[mnhh]=size(I);
A=rgb2gray(I);
I1=I;
[rowindcolumnind]=find(A<15);
pointnum=length(rowind);
rowstart=rowind-20;rowend=rowind+20;
rowstart(rowstart<1)=1;rowend(rowend>m)=m;
columnstart=columnind-20;columnend=columnind+20;
columnstart(columnstart<1)=1;columnend(columnend>n)=n;
for?num=1:pointnum
????x=rowind(num);
????y=columnind(num);???
????xstart=rowstart(num);
????xend=rowend(num);
????x1=x-xstart+1;
????ystart=columnstart(num);
????yend=columnend(num);
????y1=y-ystart+1;
????
????depthpos=A(xstart:xendystart:yend)>15;
????[locind1locind2]=find(depthpos);
????W=(locind1-x1).*(locind1-x1)+(locind2-y1).*(locind2-y1)+1;
????
????TT=1./W;T=sum(TT);?
????Aloc=I(xstart:xendystart:yend1);
????Aloc=double(Aloc(depthpos));
????R=Aloc.*TT;R=sum(R);
????I1(xy1)=R/(T+0.1);
????
????Aloc=I(xstart:xendystart:yend2);
????Aloc=double(Aloc(depthpos));
????R=Aloc.*TT;R=sum(R);
????I1(xy2)=R/(T+0.1);
????
????Aloc=I(xstart:xendystart:yend3);
????Aloc=double(Aloc(depthpos));
????R=Aloc.*TT;R=sum(R);
????I1(xy3)=R/(T+0.1);
end
figureimshow(I[]);
title(‘污染圖‘);
figureimshow(I1[]);
title(‘去污圖‘);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1209??2012-05-31?12:29??xiufu.m
?????文件?????167213??2012-05-31?12:26??1.jpg
-----------?---------??----------?-----??----
???????????????168422????????????????????2
- 上一篇:matlab實現m-rife算法
- 下一篇:matlab進行CRC編解碼
評論
共有 條評論