数字图像处理(冈萨雷斯)-4 频域平滑及锐化滤波
- 格式:ppt
- 大小:4.47 MB
- 文档页数:38
《数字图像处理》实验指导书实验一、空域图像处理一、 实验目的1熟悉CCS 集成开发环境的操作和基本功能;2熟悉MATLAB 基本图像操作;3结合实例学习如何在程序中增加图像处理算法;4理解和掌握图像的线性变换和直方图均衡化的原理和应用;5了解平滑处理的算法和用途,学习使用均值滤波、中值滤波和拉普拉斯锐化进行图像增强处理的程序设计方法;6 了解噪声模型及对图像添加噪声的基本方法。
二、 实验原理1 灰度线性变换就是将图像中所有点的灰度按照线性灰度变换函数进行变换。
)],([),(y x f T y x g =⎪⎩⎪⎨⎧<≤+-<≤+-≤≤=255),(]),([),( ]),([),(0 ),(),(y x f b g b y x f b y x f a g a y x f a y x f y x f y x g b a γβαn y m x ,2,1 ,,,2,1==2 直方图均衡化通过点运算将输入图像转换为在每一级上都有相等像素点数的输出图像。
按照图像概率密度函数PDF 的定义:1,...,2,1,0 )(-==L k n n r p k k r 通过转换公式获得:1,...,2,1,0 )()(00-====∑∑==L k n n r p r T s k j k j j j r k k3 均值(中值)滤波是指在图像上,对待处理的像素给定一个模板,该模板包括了其周围的临近像素。
将模板中的全体像素的均值(中值)来代替原来像素值的方法。
4 拉普拉斯算子如下:⎥⎥⎥⎦⎤⎢⎢⎢⎣⎡--------111181111 拉普拉斯算子首先将自身与周围的8个像素相减,表示自身与周围像素的差异,再将这个差异加上自身作为新像素的灰度。
三、实验步骤1 启动MA TLAB程序,对图像文件分别进行灰度线性变换、直方图均衡化、均值滤波、中值滤波和拉普拉斯锐化操作;添加噪声,重复上述过程观察处理结果。
2 记录和整理实验报告四、实验仪器1计算机;2 MA TLAB程序;3记录用的笔、纸。
第3章3.6原题:试解释为什么离散直方图均衡技术一般不能得到平坦的直方图?答:假设有一副图像,共有像素个数为n=MN(M行N列),像素灰度值取值范围为(0~255),那么该图像的灰度值的个数为L=256,为了提高图像的对比度,通常我们都希望像素的灰度值不要都局促到某一个狭窄的范围,也就是我们通常说的图像灰度值的动态分布小。
最好是在有效灰度值取值范围上,每个灰度值都有MN/L个像素,这个时候我们就可以得到一张对比度最理想的图像,也就是说像素的取值跨度大,像素灰度值的动态范围大。
因为直方图是PDF(概率密度函数)的近似,而且在处理中,不允许造成新的灰度级,所以在实际的直方图均衡应用中,很少见到完美平坦的直方图。
因此,直方图均衡技术不能保证直方图的均匀分布,但是却可以扩展直方图的分布范围,也就意味着在直方图上,偏向左的暗区和偏向右的亮区都有像素分布,只是不能保证每个灰度级上都有像素分布。
(百度答案:)由于离散图像的直方图也是离散的,其灰度累积分布函数是一个不减的阶梯函数。
如果映射后的图像仍然能取到所有灰度级,则不发生任何变化。
如果映射的灰度级小于256,变换后的直方图会有某些灰度级空缺。
即调整后灰度级的概率基本不能取得相同的值,故产生的直方图不完全平坦。
3.8原题:在某些应用中,将输入图像的直方图模型化为高斯概率密度函数效果会是比较好的,高斯概率密度函数为:其中m和σ分别是高斯概率密度函数的均值和标准差。
具体处理方法是将m和σ看成是给定图像的平均灰度级和对比度。
对于直方图均衡,您所用的变换函数是什么?答:直方图均衡变换函数的一般表达式如下:在回答这个问题时,有两点非常重要,需要学生表达清楚。
第一,这个表达式假定灰度值r只有正值,然而,高斯密度函数通常的取值范围是-∞~∞,认识到这点是非常重要的,认识到这点,学生才能以多种不同的方式来解决问题。
对于像标准差这样的假设,好的答案是,需要足够小,以便于当r为小于0时,在p r(r)曲线下的面积可以被忽略。
数字图像处理-空间域处理-空间滤波-锐化空间滤波器参考⾃:数字图像处理第三版-冈萨勒斯锐化处理的主要⽬的是突出灰度的过渡部分。
增强边缘和其他突变(噪声),削弱灰度变化缓慢的区域。
注意:垂直⽅向是x,⽔平⽅向是y基础图像模糊可⽤均值平滑实现。
因均值处理与积分类似,在逻辑上,我们可以得出锐化处理可由空间微分来实现。
微分算⼦的响应强度与图像的突变程度成正⽐,这样,图像微分增强边缘和其他突变,⽽削弱灰度变化缓慢的区域。
微分算⼦必须保证以下⼏点:(1)在恒定灰度区域的微分值为0;(2)在灰度台阶或斜坡处微分值⾮0;(3)沿着斜坡的微分值⾮0⼀维函数f(x)的⼀阶微分定义: ⼆阶微分定义:对于⼆维图像函数f(x,y)是⼀样的,只不过我们将沿着两个空间轴处理偏微分。
数字图像的边缘在灰度上常常类似于斜坡过渡,这样就导致图像的⼀阶微分产⽣较粗的边缘。
因为沿着斜坡的微分⾮0。
另⼀⽅⾯,⼆阶微分产⽣由0分开的⼀个像素宽的双边缘。
由此我们得出结论,⼆阶微分在增前细节⽅⾯⽐⼀阶微分好得多。
⼆阶微分-拉普拉斯算⼦我们要的是⼀个各向同性滤波器,这种滤波器的响应与滤波器作⽤的图像的突变⽅向⽆关。
也就是说,各向同性滤波器是旋转不变的,即将原图像旋转后进⾏滤波处理的结果和先对图像滤波然后再旋转的结果相同。
最简单的各向同性微分算⼦,即拉普拉斯算⼦⼀个⼆维图像函数f(x,y)的拉普拉斯算⼦定义为:任意阶微分都是线性操作,所以拉普拉斯变换也是⼀个线性算⼦。
于是:对应的滤波模板为下图a,这是⼀个旋转90°的各向同性模板,另外还有对⾓线⽅向45°的各向同性模板,还有其他两个常见的拉普拉斯模板。
a、b与c、d的区别是符号的差别,效果是等效的拉普拉斯是⼀种微分算⼦,因此它强调的是图像中灰度的突变。
将原图像和拉普拉斯图像叠加,可以复原背景特性并保持拉普拉斯锐化处理的效果。
如果模板的中⼼系数为负,那么必须将原图像减去拉普拉斯变换后的图像,从⽽得到锐化效果。
1.1 图像与图像处理的概念图像(Image):使用各种观测系统以不同形式和手段观测客观世界而获得的,可以直接或间接作用于人眼并进而产生视觉的实体。
包括:·各类图片,如普通照片、X光片、遥感图片;·各类光学图像,如电影、电视画面;·客观世界在人们心目中的有形想象以及外部描述,如绘画、绘图等。
数字图像:为了能用计算机对图像进行加工,需要把连续图像在坐标空间和性质空间都离散化,这种离散化了的图像是数字图像。
图像中每个基本单元叫做图像的元素,简称像素(Pixel)。
数字图像处理(Digital Image Processing):是指应用计算机来合成、变换已有的数字图像,从而产生一种新的效果,并把加工处理后的图像重新输出,这个过程称为数字图像处理。
也称之为计算机图像处理(Computer Image Processing)。
1.2 图像处理科学的意义1.图像是人们从客观世界获取信息的重要来源·人类是通过感觉器官从客观世界获取信息的,即通过耳、目、口、鼻、手通过听、看、味、嗅和接触的方式获取信息。
在这些信息中,视觉信息占70%。
·视觉信息的特点是信息量大,传播速度快,作用距离远,有心理和生理作用,加上大脑的思维和联想,具有很强的判断能力。
·人的视觉十分完善,人眼灵敏度高,鉴别能力强,不仅可以辨别景物,还能辨别人的情绪。
2.图像信息处理是人类视觉延续的重要手段非可见光成像。
如:γ射线、X射线、紫外线、红外线、微波。
利用图像处理技术把这些不可见射线所成图像加以处理并转换成可见图像,可对非人类习惯的那些图像源进行加工。
3.图像处理技术对国计民生有重大意义图像处理技术发展到今天,许多技术已日益趋于成熟,应用也越来越广泛。
它渗透到许多领域,如遥感、生物医学、通信、工业、航空航天、军事、安全保卫等。
1.3 数字图像处理的特点1. 图像信息量大每个像素的灰度级至少要用6bit(单色图像)来表示,一般采用8bit(彩色图像),高精度的可用12bit 或16bit。
数字图像处理课件(冈萨雷斯第三版)复习材料(1) 名词解释RGB Red Green Blue,红绿蓝三原色CMYK Cyan Magenta yellow blacK , 用于印刷的四分色HIS Horizontal Situation Indicator 水平位置指示器FFT Fast Fourier Transform Algorithm (method) 快速傅氏变换算法CWT continuous wavelet transform 连续小波变换DCT D iscrete Cosine Transform 离散余弦变换DWT DiscreteWaveletTransform 离散小波变换CCD Charge Coupled Device 电荷耦合装置Pixel: a digital image is composed of a finite number of elements,each of which hasa particular lication and value,theseelements are called pixel 像素DC component in frequency domain 频域直流分量GLH Gray Level Histogram 灰度直方图Mather(basic)wavelet:a function (wave) used to generate a set of wavelets, 母小波,用于产生小波变换所需的一序列子小波Basis functions basis image 基函数基图像Multi-scale analysis 多尺度分析Gaussian function 高斯函数sharpening filter 锐化滤波器Smoothing filter/convolution 平滑滤波器/卷积Image enhancement /image restoration 图像增强和图像恢复(2)问答题1. Cite one example of digital imageprocessingAnswer: In the domain of medical image processing we may need to inspect a certain class of images generated by an electron microscope to eliminate bright, isolated dots that are no interest.2.Cite one example of frequency domain operation from the following processing result, make a general comment about ideal highpass filter (figure B) and Gaussian highpass filter(figure D)A.Original imageB.ideal highpass filterIn contrast to the ideal low pass filter, it is to let all the signals above the cutoff frequency fc without loss, and to make all the signals below the cutoff frequency of FC without loss of.C.the result of ideal highpass filterD.Gaussian highpass filterHigh pass filter, also known as "low resistance filter", it is an inhibitory spectrum of the low frequency signal and retain high frequency signal model (or device). High pass filter can make the high frequency components, while the high-frequency part of the frequency in the image of the sharpThe law of sampling process should be followed, also called the sampling theorem and the sampling theorem. The sampling theorem shows the relationship between the sampling frequency and the signal spectrum, and it is the basic basis of the continuous signal discretization. In analog / digital signal conversion process, when the sampling frequency fs.max greater than 2 times the highest frequency present in the signal Fmax fs.max>2fmax, sampling digital signal completely retained the information in the original signal, the general practical application assurance sampling frequency is 5 ~ 10 times higher than that of the signal of the high frequency; sampling theorem, also known as the Nyquist theorem6.A mean filter is a linear filter but a median filter is not, why?Mean filter is a typical linear filtering algorithm, it is to point to in the target pixels in the image to a template, this template including its surrounding adjacent pixels and the pixels in itself.To use in the template to replace all the pixels of average pixel values.Linear filter, median filter, also known as the main method used in the bounded domain average method.Median filter is a kind of commonly used nonlinear smoothing filter and its basic principle is to put the little value in a digital image or sequence to use value at various points in the field of a point at which the value to replace, its main function is to let the surrounding pixel gray value differences between larger pixel change with the surrounding pixels value close to the values, which can eliminate the noise of the isolated points, so median filter to filter out the salt and pepper noise image is very effective.(3)算法题1.The following matrix A is a 3*3 image and B is 3*3 Laplacian mask, what will be the resulting image? (Note that the elements beyond the border remain unchanged)2.Develop an algorithm to obtain the processing result B from original image A3.Develop an algorithm which computes the pseudocolor image processing by means of fourier tramsformAnswer:The steps of the process are as follow:(1) Multiply the input image f(x,y) by (-1)x+y to center the transform;(2) Compute the DFT of the image from (1) to get power spectrum F(u,v) of Fourier transform.(3) Multiply by a filter functionh(u,v) .(4) Compute the inverse DFT of the result in (3).(5) Obtain the real part of the result in (4).(6) Multiply the result in (5) by(-1)x+y4.Develop an algorithm to generate approximation image series shown in the following figure b** means of down sampling.(4)编程题There are two satellite photos of night asblew.Write a program with MATLAB totell which is brighterAn 8*8 image f(i,i) has gray levels givenby the following equation:f(i,i)=|i-j|, i,j=0,1 (7)Write a program to find the outputimage obtained by applying a 3*3 medianfilter on the image f(i,j) ;note that theborder pixels remain unchanged.Answer:1.Design an adaptive local noise reduction filter and apply it to an image with Gaussian noise. Compare the performance of the adaptive local noise reduction filter with arithmetic mean and geometric mean filter.Answer:clearclose all;rt=imread('E:\数字图像处理\yy.bmp');gray=rgb2gray(rt);subplot(2,3,1);imshow(rt);title('原图像') ;subplot(2,3,2);imshow(gray);title('原灰度图像') ;rtg=im2double(gray);rtg=imnoise(rtg,'gaussian',0,0.005)%加入均值为0,方差为0.005的高斯噪声subplot(2,3,3);imshow(rtg);title('高噪点处理后的图像');[a,b]=size(rtg);n=3;smax=7;nrt=zeros(a+(smax-1),b+(smax-1));for i=((smax-1)/2+1):(a+(smax-1)/2)for j=((smax-1)/2+1):(b+(smax-1)/2)nrt(i,j)=rtg(i-(smax-1)/2,j-(smax-1)/2);endendfigure;imshow(nrt);title('扩充后的图像');nrt2=zeros(a,b);for i=n+1:a+nfor j=n+1:b+nfor m1=3:2m2=(m1-1)/2;c=nrt2(i-m2:i+m2,j-m2:j+m2);%使用7*7的滤波器Zmed=median(median(c));Zmin=min(min(c));Zmax=max(max(c));A1=Zmed-Zmin;A2=Zmed-Zmax;if(A1>0&&A2<0)B1=nrt2(i,j)-Zmin;B2=nrt2(i,j)-Zmax;if(B1>0&&B2<0)nrt2(i,j)= nrt2(i,j);elsenrt2(i,j)=Zmed;endcontinue;endendendendnrt3=im2uint8(nrt2);figure;imshow(nrt3);title('自适应中值滤波图');2.Implement Wiener filter with “wiener2” function of MatLab to an image with Gaussian noise and compare the performance with adaptive local noise reduction filter.代码如下:>> I=imread('E:\数字图像处理\yy.bmp');>>J=rgb2gray(I);>>K = imnoise(J,'gaussian',0,0.005);>>L=wiener2(K,[5 5]);>>subplot(1,2,1);imshow(K);title('高噪点处理后的图像');>>subplot(1,2,2);imshow(L);title('维纳滤波器处理后的图像');3. Image smoothing with arithmetic averaging filter (spatial convolution).图像平滑与算术平均滤波(空间卷积)。