实验四 图像恢复技术

实验三 图像恢复技术
一、 实验目的
掌握退化图像中常见噪声模型及参数估计方法;加深对几种常用的图像复原方法的理解;通过查理大帝传Matlab开发环境实现参数维纳滤波器复原图像。
二、 实验内容
1. 对各种常见噪声模型进行仿真实现;
2. 把仿真噪声加入纯净图像上形成退化图像,让后对噪声进行参数估计,并与原设定参数进行比较以衡量估计的准确性;
3. 仿真几种常见噪声,并用参数维纳滤波器方法进行图像复原;
4. 观察复原效果,并进行仔细讨论。
三、 知识要点与范例
1. 图像恢复退化模型
图像恢复问题可以分为两大类:
1) 假定系统退化函数H为恒等算子,而只考虑环境噪声引起退化的情况;
2) 同时考虑H和环境噪声
2. 噪声模型
对噪声的行为和效果进行仿真的能力是图像恢复处理中的重点。除了周期噪声,通常假定噪声与象素坐标无关。
Matlab噪声仿真函数为:
g = imnoise(f, type, parameters);
常见的噪声(高斯、椒盐噪声)的仿真实例如下:
g = imnoise(f, ‘gaussian’, m, var);
g = imnoise(f,’salt & pepper’, d); (where ’d’ represents the noise density).
3. 产生具有某种固定分布的空间随机噪声.
MATLAB中两个常用的随机分布产生函数是:
rand(均匀分布噪声), randn(标准正态分布噪声)
空间随机噪声是有各自的PDF CDF所决定的。除了有上面所讲的immoise噪声产生函数外, 具有某种规定 CDF的大部分随机噪声都可由均匀分布的随机量(这里用w表示)通过某个随机数产生方程来生成。也就是说,给定w ~ (0,1), 具有某个确定分布Fz 的随机变量z 偶合症可以通过解如下方程获得:
z = Fz-1(w).
如:
变量z 满足如下Rayleigh分布:
则:
, 这个方程也通常叫做随机数产生方程 (RNGE)
对其他类型的 RNGEs, 请见参考教材[2]146页。
产生两种噪声的Matlab程序实例
(1) generate the gaussian noise of 500*500 size, mean=0, variance=1
R = imnoise2(‘gaussian’, 500,500, 0, 1)
Whose histogram is below, generated by:
hist((R:), 50);
(2) rayleigh noise (a and b is by default)
r= imnoise2(‘rayleight’, 100000, 1)
4. 从灰度直方图估计噪声的方法
所要进行估计的参数主要有两个:均值和方差;参考教材[2]中的Matlab实现函数为:
[v, unv] = statmoments(p, n)
选取无特征背景区域 (ROI)的函数为:
B = roipoly(f, c, r), or [B, r, c] = roipoly(…) for chose interactively.
实例:仿真某种噪声加入到某个无噪声的图像,然后把上面方法得到的参数估计与原参数进行比较。
f=imread('Fig0504(a)(noisy_image).tif');
[B, c, r] = roipoly(f)
subplot(221);imshow(f);
subplot(222);imshow(B);
[p,npix] = histroi(f,c,r);
subplot(223);bar(p,1);
[v,unv]=statmoments(p,2);
x = imnoise2(‘gaussian’, npix, 1, floor(unv), floor(sqrt(v)));
[v,unv]=statmoments(p,2)
x = imnoise2('gaussian', npix, 1, floor(unv(1)), floor(sqrt(unv(2))));
subplot(224), hist(x, 130);
axis([0 300 0 50])
结果:
5. 只有空间加性噪声时的图像恢复问题
当退化仅仅是由上式所示的加性噪声造成时,可以采用教材第三章中所讲的图像强技术。
Matlab函数spfilt(见附录)集成了差不多所有空间滤波的功能,包括 including: arithmetic mean, geometric mean, harmonic mean, contraharmonic mean, median, max, min, midp
oint, alpha-trimmed mean
用上面的函数进行图像复原的实例:原图像是一幅电路板的联想p709x-image,图像的相关信息为: unit8, TIFF, 448*464 (heigh*width); 对图像加入椒盐噪声后再用各种方法进行恢复:
屯留二中% adding pepper-salt noise
上海基本药物目录[M, N]=size(f);
R=imnoise2('salt & pepper',M, N, 0.1,0);
c = find(R==0);
gp = f;
gp(c)=0;
% the following codes generate only salt noise only: (see upper-middle figure)
R=imnoise2('salt & pepper',M, N, 0,0.1);
c = find(R==1);
gs = f;
gs(c)=255;
%the upper-right figure is generated by filtering pepper noise using contraharmonic filter with Q>0:
fp = spfilt(gp, 'chmean',3,3,1.5);
%the bottom-left figure is generated by filtering salt noise using contraharmonic filter with Q<0:
fs = spfilt(gs, 'chmean',3,3,-1.5);
%the bottom-middle figure is generated by filtering pepper noise using max filter:
fpmax = spfilt(gp,'max',3,3);
%the bottom-right figure is generated by filtering salt noise using min filter:
fsmin = spfilt(gs,'min',3,3);
======================================================================
6. 空间退化函数建模
有先验知识的退化函数建模函数:
PSF = fspecial(‘motion’, len , theta); %it approximates the effects of linear motion of a camera.
为比较各种恢复方法而设计的一种合适的测试模式:
C = checkerboard(NP, M, N);
一个产生“checkerboard 图像和其测试图像的实例:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
f = checkerboard(8);
PSF = fspecial ('motion', 7, 45);  % generate degradation function
gb = imfilter(f, PSF, 'circular');  % producing degraded image
noise = imnoise(zeros(size(f)), 'gaussian', 0, 0.001); % simulate Gaussian noise
g = gb + noise;          % generate blurred image by degradation and noise
fr = pixeldup(f, 8);        % pixel replication to form 512*512 image
gbr = pixeldup(gb, 8);
nr = pixeldup(noise,8);
gr = pixeldup(g, 8);
subplot(221);imshow(fr,[]);
title(' original test pattern of size 512*512');
subplot(222);imshow(gbr, []);
title(' degreded image by PSF');
subplot(223);imshow(nr, []);
title(' gaussian noise image');
subplot(224);imshow(gr, []);
title('blurred image by degradation and noise');
++++++++++++++++++++++++++++++++++++
7. Wiener filtering
基本原理:
河北人事厅Matlab实现:
fr = deconvwnr(g, PSF, NACORR, FACORR);
四、 参数维纳滤波参考程序
两种维纳滤波方法与直接逆滤波方法间的比较: +++++++++++++++++++++++++++++++++
f = checkerboard(8);  % the original undegraded image
PSF = fspecial ('motion', 7, 45);  % degradation function
gb = imfilter(f, PSF, 'circular');  % producing degraded image

本文发布于:2024-09-25 17:16:12,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/477408.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:噪声   图像   进行
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议