2014-06-27 53 views
0

我應該設計和實現一個自適應濾波器來消除醫學圖像中的脈衝噪聲! 我是圖像處理新手。並不知道如何設計一個過濾器! 我檢查了預定義的過濾器...他們不是我想要的! 請幫助這是我的B.S.項目!如何設計和實現用於脈衝噪聲去除的自適應濾波器?

+0

有點含糊。我想你應該決定是否需要線性濾波器和非線性濾波器。這可能是一個開始。 – Jiminion

+0

當我學習了自適應濾波器之後,它們在某些情況下像線性濾波器一樣工作,並且像其他濾波器中的非線性濾波器一樣... 您的建議是什麼? –

+0

你可以描述空間衝動嗎?他們總是積極的還是消極的?或兩者?如果你有這個尺寸,我會建議使用線性濾波器來平滑它(保留信息)或者非線性濾波器來完全去除它(不保留所有信息)。 – Jiminion

回答

0

脈衝噪聲通常使用median濾波器進行處理。
要構建自適應濾波器,我會使用統計數據來確定在窗口內是否有光滑的部分。

我會在使用Windows的圖像上工作。
在每個窗口中我會檢查中位數和平均值。
如果他們彼此遠離,我會應用median過濾器,否則,應用本地LPF過濾器什麼也不做。

它是簡單...

-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); %%過濾器 窗口