使用 MATLAB / Octave 对具有高斯噪声的图像进行去噪

信息处理 图像处理 matlab 图像分割 去噪 八度
2021-12-24 02:54:54

当观察到的图像是

f=u+v
在哪里u是恢复的图像(是我想要恢复的图像)和v是高斯噪声。

恢复u,我解决了以下最小化问题:

minuH1(Ω)Ωγ|u(x)|2dx+Ω(f(x)u(x))2dx,
其中是正则化系数, size( )。γΩ=[0,n]×[0,m][n,m]=u

我想使用 MATLAB 求解 PDE(欧拉-拉格朗日):

div(γu)+u=finΩun=0inΩ

谁能帮我解决这个问题?谢谢!

我尝试了以下代码:

clear all, close all,clc

uor=imread('gourd.bmp'); % the original image 
u0 = imnoise(uor,'gaussian',0,0.01);
u0=double(u0);
[m n]=size(u0);
uor=double(uor);
u=u0;
c=0.028;
h=1;     
for Iter=1:50, 
    for i=2:m-1,
      for j=2:n-1,
          Lap=0.003*(u(i+1,j)+u(i-1,j)-4*u(i,j)+u(i,j+1)+u(i,j-1));
          u(i,j)=(u0(i,j)+(1/(2*c*h*h))*Lap);
     end
    end
    for i=2:m-1,
          u(i,1)=u(i,2);
          u(i,n)=u(i,n-1);
        end

    for j=2:n-1,
          u(1,j)=u(2,j);
          u(m,j)=u(m-1,j);
        end

        u(1,1)=u(2,2);
        u(1,n)=u(2,n-1); 
        u(m,1)=u(m-1,2);
        u(m,n)=u(m-1,n-1);

en=0.0;  
    for i=2:m-1,
      for j=2:n-1,
      ux=(u(i+1,j)-u(i,j))/h;
      uy=(u(i,j+1)-u(i,j))/h;
      fidelity=(u0(i,j)-u(i,j))*(u0(i,j)-u(i,j));

      en=en+c*fidelity;
      end
    end


Energy(Iter)=en; 

%  Error between uor and u0
 ur=reshape(u,m*n,1);
 uori=reshape(uor,m*n,1);
 residu=norm(ur-uori)/norm(uori);

 [peaksnr, snr] = psnr(uor, u);

disp(['    iter ' num2str(Iter), ' :     Error = ' num2str(residu), ...
    ' ,    Peak-snr ' num2str(-peaksnr), ' ,    SNR ' num2str(snr)]);


  end 

% show the structural similarity index for measuring image quality 
[ssimval, mapssim] = ssim(u,uor);
disp([' the structural similarity index is ' num2str(ssimval)]);
figure,imshow(mapssim,[]); axis square; 

figure,imagesc(u); axis image; axis off; colormap(gray);

原图在这里: https ://www.dropbox.com/s/4bccby1f4lxp4j9/gourd.rar?dl=0

葫芦

最好的祝福

1个回答

您正在尝试解决所谓的Perona Malik 非线性扩散问题(有时人们错误地将其称为各向异性扩散)。

无论如何,最简单的代码是The MATLAB File Exchange上的Anisotropic Diffusion (Perona & Malik)

Fast Anisotropic Curvature Preserving Smoothing(也在文件交换 - Fast Anisotropic Curvature Preserving Smoothing )中有一个更高级的(真实各向异性)算法

享受...