我应该设计并实现一个自适应滤波器,以消除医学图像中的脉冲噪声! 我是图像处理的新手。并且不知道如何设计过滤器! 我检查了预定义的过滤器......它们不是我想要的! 请帮助这是我的B.S.项目!
答案 0 :(得分:0)
通常使用median
滤镜处理脉冲噪音
为了构建自适应滤波器,我将使用统计数据来确定窗口内是否有某些东西要平滑。
我会使用windows处理图像
在每个窗口中,我都会检查中位数和平均值
如果它们彼此相距很远,我会应用median
过滤器,否则,应用本地LPF过滤器什么都不做。
很简单......
答案 1 :(得分:-1)
我找到了一篇关于它的论文,这是我实施的代码
function adaptive()
I = imread('1.png');
x = rgb2gray(I);
%%-------adding Noise-----------------------
disp('Noise density lies between 0 and 1');
disp(' ');
ND = input('Enter Noise Density [0.5] : ');
if isempty(ND)
ND = 0.5;
end
y=x;
Narr = rand(size(y));
N = Narr;
N(N>=ND)=0;
N1 = N;
N1 = N1(N1>0);
Imn=min(N1(:));
Imx=max(N1(:));
N=(((N-Imn).*(255-0))./(Imx-Imn));
y(Narr<ND) = N(Narr<ND);
y=double(y);
%%------noise detection------------------------
adj = imadjust(y);
L = max(adj);
[M,N] = size(y);
for i = 1:M
for j = 1:N
if y(i,j) == L(j)-1 || y(i,j) == 0
alpha(i,j) = 1; %%the value 1 presents the “noise pixel”
else
alpha(i,j) = 0; %%the value 0 presents the “noise-free pixel”.
end
end
end
K=0;
for i = 1:M
for j = 1:N
if alpha(i,j) == 1;
K=K+1; %%total number of the “noise pixel”, K.
end
end
end
n = K / (M*N); %%the ratio of the “noise pixels” to
%%the total number of pixels contained in the image
%%------noise elimination------------------------
%%R=1;
R = floor(0.5 * sqrt( 7 / (1-n) ));
m = ones(size(y(:)));
for i = 1:M
for j = 1:N
if alpha(i,j) == 1 %% this is a noise pixel
nnum=0; %%noise number
while nnum <= 8
R = R+1; %% This will make the filter window 2pixels larger
clear tmp;
if i-R <= 0 || i+R >= M
while i-R <= 0
R=R-1;
end
while i+R >= M
R=R-1;
end
end
if j-R <= 0 || j+R >= N
while i-R <= 0
R=R-1;
end
while i+R >= M
R=R-1;
end
end
tmp = y( i-R:i+R , j-R:j+R ); %% filter window
w = 2*R +1 ; %% Size of filter window
for s = 1:w
for p = 1:w
if tmp(s,p) == 0 || tmp(s,p) == L(j)-1
nnum=nnum+1; %%number of free noise pixels in the window
end
end
end
end
clear temp;
temp = y( i-R:i+R , j-R:j+R ); %% filter window
S = sort(temp(:));
if S(1) < S(R+1) && S(R+1) < S(w) && 0 < S(R+1) && S(R+1) < L(j)
m(i,j) = S(R+1);
end
if S(1) >= S(R+1) || S(R+1) >= S(w) || S(R+1) == L(j) && S(R+1) == 0
t = y(i,j-1);
m(i,j) = t;
end
end
end
end
for i = 1:M
for j = 1:N
if alpha(i,j) == 0 %% the value of z(i,j) is copied directly as the value of y(i,j).
z = y(i,j);
else
z = m(i,j); %%the output value z(i,j) is equal to m(i,j).
end
end
end
imshow(x);
figure,imshow(y);
figure,imshow(z);
end
我有错误,请帮忙!
错误:内存不足。键入HELP MEMORY以获取选项。 自适应错误(第96行) m(i,j)= t;
和
下标索引必须是实数正整数或 逻辑值。 自适应错误(第73行) tmp = y(i-R:i + R,j-R:j + R); %%过滤器 窗口