资源简介
InSAR相位降噪滤波是其中重要的一环,旋滤波程序是一种方向滤波方法,本程序用MATLAB编写。
代码片段和文件信息
clear all;
x=imread(‘020.bmp‘);%输入文件
g=double(rgb2gray(x));
[growgcol]=size(g);
Dij(11:8)=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%旋滤波部分的程序,分成8个方向,取方差最小为滤波方向。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=4:grow-4
for j=4:gcol-4
B(1:81:7)=[g(i-3j) g(i-2j) g(i-1j)g(ij) g(i+1j) g(i+2j) g(i+3j);
g(i-3j+2) g(i-2j+1) g(i-1j+1)g(ij) g(i+1j-1) g(i+2j-1) g(i+3j-2);
g(i-3j+3) g(i-2j+2) g(i-1j+1)g(ij) g(i+1j-1) g(i+2j-2) g(i+3j-3);
g(i-1j+3) g(i-1j+2) g(ij+1) g(ij)g(ij-1) g(i+1j-2) g(i+1j-3);
g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3);
g(i-1j-3) g(i-1j-2) g(ij-1) g(ij)g(ij+1) g(i+1j+2) g(i+1j+3);
g(i-3j-3) g(i-2j-2) g(i-1j-1) g(ij)g(i+1j+1) g(i+2j+2) g(i+3j+3);
g(i-3j-2) g(i-2j-1) g(i-1j+1) g(ij)g(i+1j+1) g(i+2j+1) g(i+3j+2)];
B=double(B‘);
Dij=Dij+std(B);
%end
%end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%根据方向,确定滤波方向,进行中值滤波,输入新的矩阵g1中。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[kkk]=find(Dij==min(Dij));
Direction(ij)=kk;
switch (kk(1))%根据方向确定入口
case 1
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);%进行中值滤波
case 2
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);
case 3
B1=[g(i-3j+3) g(i-2j+2) g(i-1j+1)g(ij) g(i+1j-1) g(i+2j-2) g(i+3j-3)];
B1=double(B1);
g1(ij)=median3(B1);
case 4
B1=[g(i-1j+3) g(i-1j+2) g(ij+1) g(ij)g(ij-1) g(i+1j-2) g(i+1j-3)];
B1=double(B1);
g1(ij)=median3(B1);
case 5
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);
case 6
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);
case 7
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);
case 8
B1=[g(ij-3) g(ij-2) g(ij-1) g(ij)g(ij+1) g(ij+2) g(ij+3)];
B1=double(B1);
g1(ij)=median3(B1);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%将文件重新存回原目录
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3197 2008-02-10 22:20 spinfilter.m
----------- --------- ---------- ----- ----
3197 1
- 上一篇:hungarian.m
- 下一篇:基于MATLAB的工频干扰陷波器设计
评论
共有 条评论