数字图像处理实验6冈萨雷斯.
- 格式:doc
- 大小:152.50 KB
- 文档页数:8
数字图像处理冈萨雷斯第二版答案数字图像处理冈萨雷斯第二版答案【篇一:数字图像处理第三版 (冈萨雷斯,自己整理的2)】特数。
通常的传输是以一个开始比特,一个字节(8 比特)的信息和一个停止比特组成的包完成的。
基于这个概念回答以下问题:(b) 以750k 波特 [这是典型的电话dsl(数字用户线)连接的速度]传输要用多少时间?2.两个图像子集s1和s2图下图所示。
对于v={1},确定这两个子集是(a)4-邻接,(b)8-邻接,(c)m-邻接。
a) s1 和s2 不是4 连接,因为q 不在n4(p)集中。
(b) s1 和s2 是8 连接,因为q 在n8(p)集中。
(c) s1 和s2 是m 连接,因为q 在集合nd(p)中,且n4(p)∩ n4(q)没有v 值的像素3. 考虑如下所示的图像分割(a) 令v={0,1}并计算p 和q 间的4,8,m 通路的最短长度。
如果在这两点间不存在特殊通路,试解释原因。
(b) 对于v={1,2}重复上题。
解:(a) 当v={0,1}时,p 和q 之间不存在4 邻接路径,因为不同时存在从p 到q 像素的4 毗邻像素和具备v 的值,如图(a)p 不能到达q。
8 邻接最短路径如图(b),最短长度为4。
m邻接路径如图(b)虚线箭头所示,最短长度为5。
这两种最短长度路径在此例中均具有唯一性。
(b) 当v={1, 2}时,最短的4 邻接通路的一种情况如图(c)所示,其长度为6,另一种情况,其长度也为6;8 邻接通路的一种情况如图(d)实线箭头所示,其最短长度为4;m 邻接通路的一种情况如图(d)虚线箭头所示,其最短长度为6.或解: (1) 在v={0,1}时,p和q之间通路的d4距离为∞,d8距离为4,dm距离为5。
(2) 在v={1,2}时,p和q之间通路的d4距离为6,d8距离为4,dm距离为6。
4为什么一般情况下对离散图像的直方图均衡化并不能产生完全平坦的直方图?【因为同一个灰度值的各个象素没有理由变换到不同灰度级,所以数字图像的直方图均衡化的结果一般不能得到完全均匀分布的直方图,只是近似均匀的直方图。
Digital Image ProcessingProject chapter:Chapter 6Project number:Proj06-01 ~ Proj06-04 Student's name:Student's number:Class:ContentsWEB-SAFE COLORS (2)PSEUDO-COLOR IMAGE PROCESSING (2)COLOR IMAGE ENHANCEMENT BY HISTOGRAM PROCESSING (5)COLOR IMAGE SEGMENTATION (7)Web-Safe ColorsExp. 20,PROJECT 06-01ObjectiveTo know what are Web-safe colors, how to generate the RGB components for a given jpeg color image, or convert an image to RGB manually?Requirements(a) Write a computer program that converts an arbitrary RGB color image to a web-safe RGB image (see Fig. 6.10 for a definition of web-safe colors).(b) Download the image in Fig. 6.8 and convert it to a web-safe RGB color image. Figure 6.8 is given in jpg format, so convert your result back to jpg (see comments at the beginning of this project).Figure 1 Fig6.08.jpgTechnical discussion【1】B = fix(A)rounds the elements of A toward zero, resulting in an array of integers.For complex A, the imaginary and real parts are rounded independently.【2】imwrite(A,filename,fmt)writes the image A to the file specified by filename in the format specified by fmt. Program listingsI=imread('Fig6.08.jpg');subplot(131);imshow(I);title('original');I1=fix((I/51)*51);subplot(132);imshow(I1);title('web-safe colors(jpg)');imwrite(I1,'web-safe colors.jpeg','jpeg');subplot(133);I=imread('web-safe colors.jpeg');imshow(I);title('web-safe colors(jpeg)');Discussion of resultsoriginal web-safe colors(jpg)web-safe colors(jpeg)Figure 2 results of project 06-01Pseudo-Col or Image ProcessingExp. 21,PROJECT 06-02ObjectiveTo know when the highpass filtering H hp(u,v) can be obtained by using the relation 1-H lp(u,v).Requirements(a)Implement Fig. 6.23, with the characteristic that you can specify two ranges of gray-level values for the input image and your program will output an RGB image whose pixels have a specified color corresponding to one range of gray levels in the input image, and the remaining pixels in the RGB image have the same shade of gray as they had in the input image.(b) Download the image in Fig. 6.22(a) and process it with your program so that the river appears yellow and the rest of the pixels are the same shades of gray as in the input image.Figure 3 Fig6.22(a).jpgTechnical discussion【1】RGB componentsrgb_R=I(:, :, 1);rgb_G=I(:, :, 2);rgb_B=I(:, :, 3);Program listingsI=imread('Fig6.22(a).jpg');subplot(121);imshow(I);title('original');I=double(I);[m,n]=size(I);L=256;for i=1:mfor j=1:nif I(i,j)<L/4R(i,j)=0;G(i,j)=4*I(i,j);B(i,j)=L;else if I(i,j)<=L/2R(i,j)=0;G(i,j)=L;B(i,j)=-4*I(i,j)+2*L;else if I(i,j)<=3*L/4R(i,j)=4*I(i,j)-2*L;G(i,j)=L;B(i,j)=0;elseR(i,j)=L;G(i,j)=-4*I(i,j)+4*L;B(i,j)=0;endendendendendfor i=1:mfor j=1:nG2C(i,j,1)=R(i,j);G2C(i,j,2)=G(i,j);G2C(i,j,3)=B(i,j);endendG2C=G2C/256;subplot(122);imshow(G2C);title('Pseudo-Color');Discussion of resultsoriginal Pseudo-ColorFigure 4 results of project 06-02Color Image Enhancement by Histogram ProcessingExp. 22,PROJECT 06-03ObjectiveTo know how to implement image enhancement for color images by histogram processing. Note that the definition of histogram for color images differs from that of histogram for gray images.RequirementsDownload the dark-stream color picture in Fig. 6.35. Histogram-equalize the R,G,and B images separately using the histogram-equalization program and convert the imageback to jpg format.Figure 5 Fig6.35(5).jpgTechnical discussion【1】C = cat(dim, A1, A2, A3, A4, ...)concatenates all the input arrays (A1, A2, A3, A4, and so on) along array dimension dim.Program listingsI=imread('Fig6.35(5).jpg');subplot(121);imshow(I);title('original');a=I(:,:,1);b=I(:,:,2);c=I(:,:,3);A=histeq(a);B=histeq(b);C=histeq(c);I3=cat(3,A,B,C);subplot(122);imshow(I3);title('histogram processing');Discussion of resultsoriginal histogram processingFigure 6 results of project 06-03Color Image SegmentationExp. 23,PROJECT 06-04ObjectiveColor image segmentation is a big issue in image processing. This students need to know the basics of this topic.RequirementsDownload Fig. 6.28(b) and duplicate Example 6.15, but segment instead the darkest regions in the image.Figure 7 Fig6.30(01).jpgTechnical discussion【1】RGB2 = im2double(RGB)converts the truecolor image RGB to double precision, rescaling the data if necessaryProgram listingsrgb=imread('Fig6.30(01).jpg');subplot(221);imshow(rgb);title('original');rgb1=im2double(rgb);r=rgb1(:,:,1);g=rgb1(:,:,2);b=rgb1(:,:,3);r1=r(129:256,86:170);r1_u=mean(mean(r1(:)));[m,n]=size(r1);sd1=0.0;for i=1:mfor j=1:nsd1=sd1+(r1(i,j)-r1_u)*(r1(i,j)-r1_u);endendr1_d=sqrt(sd1/(m*n));r2=zeros(size(rgb1,1),size(rgb1,2));ind=find((r>r1_u-1.25*r1_d)&(r<r1_u+1.25*r1_d));r2(ind)=1;subplot(222);imshow(r2);title('segmentation');subplot(234);imshow(r);title('R component');subplot(235);imshow(g);title('G component');subplot(236);imshow(b);title('B component');Discussion of resultsoriginal segmentationR component G component B componentFigure 8 results of project 06-04。
《数字图像处理》实验指导书实验一、空域图像处理一、实验目的1熟悉CCS集成开发环境的操作和基本功能;2熟悉MATLAB基本图像操作;3结合实例学习如何在程序中增加图像处理算法;4理解和掌握图像的线性变换和直方图均衡化的原理和应用;5了解平滑处理的算法和用途,学习使用均值滤波、中值滤波和拉普拉斯锐化进行图像增强处理的程序设计方法;6 了解噪声模型及对图像添加噪声的基本方法。
二、实验原理1 灰度线性变换就是将图像中所有点的灰度按照线性灰度变换函数进行变换。
2 直方图均衡化通过点运算将输入图像转换为在每一级上都有相等像素点数的输出图像。
按照图像概率密度函数PDF的定义:通过转换公式获得:3 均值(中值)滤波是指在图像上,对待处理的像素给定一个模板,该模板包括了其周围的临近像素。
将模板中的全体像素的均值(中值)来代替原来像素值的方法。
4 拉普拉斯算子如下:拉普拉斯算子首先将自身与周围的8个像素相减,表示自身与周围像素的差异,再将这个差异加上自身作为新像素的灰度。
三、实验步骤1 启动MATLAB程序,对图像文件分别进行灰度线性变换、直方图均衡化、均值滤波、中值滤波和拉普拉斯锐化操作;添加噪声,重复上述过程观察处理结果。
2 记录和整理实验报告四、实验仪器1计算机;2 MATLAB程序;3记录用的笔、纸。
五、实验报告内容1叙述实验过程;2提交实验的原始图像和结果图像。
六、思考题1.设定不同的斜率值和截距,显示效果会怎样?2.直方图均衡化是什么意思?它的主要用途是什么?3. 均值(中值)滤波的模板大小对处理效果有什么影响?基本函数:图像读入:imread图像显示:imshow计算直方图:imhist直方图均衡化:histeq添加噪声:imnoise滤波器定义:fspecial中值滤波:medfilt2实验二、图像的傅立叶变换一、实验目的1了解图像变换的意义和手段;2熟悉傅里叶变换的基本性质;3熟练掌握FFT方法及应用;4通过实验了解二维频谱的分布特点;5通过本实验掌握利用MATLAB编程实现数字图像的傅立叶变换及滤波锐化和复原处理;6 了解理想、巴特沃兹、高斯等不同滤波器的结构及滤波效果。
实验六图像压缩(同预习)一、实验目的1、理解有损压缩和无损压缩的概念;2、理解图像压缩的主要原则和目的;3、利用MATLAB 程序进行图像压缩。
二、实验内容1、Huffman 编码使用mat2huff,huff2mat 实现Huffman 编解码,并应用imratio 计算编码后信号的压缩率。
2、编写无损预测编解码(lossless predictive coding)程序,使p313 Figure 8.7 (c)图具有更低的熵(5.4436)。
显示预测误差(prediction error)图。
用解码程序解码,并验证解码是否正确(compare)。
3、参考p319-323,实现16×16分块离散余弦(DCT)编码,用zigzag方式保留每一块的前10个和前21个系数,再进行进行DCT解码。
编写程序并分别显示解码后的两个图。
实验程序:实验1:i=imread('Fig0804(a)(Tracy).tif'); i1=mat2huff(i);cr1=imratio(i,i1);%cr1,压缩率i2=huff2mat(i1);rmse1=compare(i,i2);figure,imshow(i);figure,imshow(i2);实验2:子程序1:function y = mat2lpc2(x, f)%本程序改自课本上那个程序,可实现更高压缩率!error(nargchk(1, 2, nargin)); % Check input argumentsif nargin < 2 % Set default filter if omittedf = 1;endx = double(x); % Ensure double for computations [m, n] = size(x); % Get dimensions of input matrixp = zeros(m, n); % Init linear prediction to 0xs = x; zc = zeros(1,n); % Prepare for input shift and pad for j = 1:length(f) % For each filter coefficient ...xs = [zc; xs(1:end - 1,:)]; % Shift and zero pad xga改加一行 p = p + f(j) * xs; % Form partial prediction sumsendy = x - round(p); % Compute the prediction error子程序2:function x = lpc2mat2(y, f)% 本程序改自课本上那个程序,可以解压error(nargchk(1, 2, nargin)); % Check input argumentsif nargin < 2 % Set default filter if omittedf = 1;endy=y';f = f(end:-1:1); % Reverse the filter coefficients[m, n] = size(y); % Get dimensions of output matrix order = length(f); % Get order of linear predictorf = repmat(f, m, 1); % Duplicate filter for vectorizingx = zeros(m, n + order); % Pad for 1st 'order' column decodes% Decode the output one column at a time. Compute a prediction based % on the 'order' previous elements and add it to the prediction% error. The result is appended to the output matrix being built.for j = 1:njj = j + order;x(:, jj) = y(:, j) + round(sum(f(:, order:-1:1) .* ...x(:, (jj - 1):-1:(jj - order)), 2));endx = x(:, order + 1:end); % Remove left paddingx=x';总程序:f=imread('Fig0807(c)(Aligned).tif');e=mat2lpc2(f);figure,imshow(mat2gray(e));h=entropy(e);c=lpc2mat2(e);figure,imshow(c,[]);rmse=compare(f,c);实验三:i=imread('Fig0804(a)(Tracy).tif');i=im2double(i);mask1=[1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 01 1 1 0 0 0 0 0 0 0 0 0 0 0 0 01 1 0 0 0 0 0 0 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ];mask2=[1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 01 1 1 1 1 0 0 0 0 0 0 0 0 0 0 01 1 1 1 0 0 0 0 0 0 0 0 0 0 0 01 1 1 0 0 0 0 0 0 0 0 0 0 0 0 01 1 0 0 0 0 0 0 0 0 0 0 0 0 0 01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ];T=dctmtx(16);B=blkproc(i,[16 16],'P1*x*P2',T,T'); i1=blkproc(B,[16 16],'P1.*x',mask1); i2=blkproc(B,[16 16],'P1.*x',mask2); ii1=blkproc(i1,[16 16],'P1*x*P2',T',T); ii2=blkproc(i2,[16 16],'P1*x*P2',T',T); figure,imshow(ii1);figure,imshow(ii2);。
数字图像处理第三版中文答案解析引言《数字图像处理》是一本经典的图像处理教材,目前已经出版了第三版。
本文是对该书答案解析的总结,将分析和解释书中的问题和答案。
目录•第一章:绪论•第二章:数字图像基础•第三章:灰度变换•第四章:空间滤波•第五章:频域滤波•第六章:图像复原•第七章:几何校正•第八章:彩色图像处理•第九章:小波与多分辨率处理第一章:绪论本章主要介绍了数字图像处理的概念和基本步骤。
答案解析中包括对一些基本概念和术语的解释,以及相关的数学公式和图像处理方法的应用。
第二章:数字图像基础本章介绍了数字图像的表示和存储方法,以及图像的采样和量化过程。
答案解析中详细解释了图像的像素值和灰度级之间的关系,以及采样频率和量化步长对图像质量的影响。
第三章:灰度变换本章讲述了图像的灰度变换方法,包括线性和非线性变换。
答案解析中对不同灰度变换函数的作用和效果进行了解释,并给出了一些实例和应用。
第四章:空间滤波本章介绍了图像的空间滤波方法,包括平滑和锐化滤波。
答案解析中解释了不同滤波器的原理和效果,并给出了滤波器设计的步骤和实例。
第五章:频域滤波本章讲述了图像的频域滤波方法,包括傅里叶变换和滤波器设计。
答案解析中详细解释了傅里叶变换的原理和应用,以及频域滤波器的设计方法和实例。
第六章:图像复原本章介绍了图像的复原方法,包括退化模型和复原滤波。
答案解析中详细解释了退化模型的建立和复原滤波器的设计方法,以及如何根据退化模型进行图像复原的实例。
第七章:几何校正本章讲述了图像的几何校正方法,包括图像的旋转、缩放和平移等操作。
答案解析中给出了不同几何变换的矩阵表示和变换规则,以及几何校正的应用实例。
第八章:彩色图像处理本章介绍了彩色图像的表示和处理方法,包括RGB和HSV 等颜色模型的转换和处理。
答案解析中详细解释了不同颜色模型的表示和转换方法,以及彩色图像处理的实例和应用。
第九章:小波与多分辨率处理本章讲述了小波和多分辨率处理的方法和应用。
一、实验目的
实验六图像压缩(同预习)
1、理解有损压缩和无损压缩的概念;
2、理解图像压缩的主要原则和目的;
3、利用MATLAB 程序进行图像压缩。
二、实验内容
1、Huffman 编码
使用 mat2huff,huff2mat 实现Huffman 编解码,并应用imratio 计算编码后信
号的压缩率。
2、编写无损预测编解码(lossless predictive coding)程序,使p313 Figure
8.7 (c 图具有更低的熵(5.4436)。
显示预测误差(prediction error图。
用解
码程序解码,并验证解码是否正确(compare)。
3、参考p319-323,实现16×16分块离散余弦(DCT编码,用zigzag方式保留每一块的前10个和前21个系数,再进行进行DCT解码。
编写程序并分别显示解码后的两个图。
实验程序:
实验1:
i=imread('Fig0804(a(Tracy.tif';
i1=mat2huff(i;
cr1=imratio(i,i1;%cr1,压缩率
i2=huff2mat(i1;
rmse1=compare(i,i2;
figure,imshow(i;
figure,imshow(i2;
实验2:
子程序1:
function y = mat2lpc2(x, f
%本程序改自课本上那个程序,可实现更高压缩率!
error(nargchk(1, 2, nargin; % Check input arguments
if nargin < 2 % Set default filter if omitted
f = 1;
end
x = double(x; % Ensure double for computations
[m, n] = size(x; % Get dimensions of input matrix
p = zeros(m, n; % Init linear prediction to 0
xs = x; zc = zeros(1,n; % Prepare for input shift and pad for j = 1:length(f % For each filter coefficient ...
xs = [zc; xs(1:end - 1,:]; % Shift and zero pad xga改加一行p = p + f(j * xs; % Form partial prediction sums
end
y = x - round(p; % Compute the prediction error
子程序2:
function x = lpc2mat2(y, f
% 本程序改自课本上那个程序,可以解压
error(nargchk(1, 2, nargin; % Check input arguments
if nargin < 2 % Set default filter if omitted
f = 1;
end
y=y';
f = f(end:-1:1; % Reverse the filter coefficients
[m, n] = size(y; % Get dimensions of output matrix
order = length(f; % Get order of linear predictor
f = repmat(f, m, 1; % Duplicate filter for vectorizing
x = zeros(m, n + order; % Pad for 1st 'order' column decodes
% Decode the output one column at a time. Compute a prediction based % on the 'order' previous elements and add it to the prediction
% error. The result is appended to the output matrix being built.
for j = 1:n
jj = j + order;
x(:, jj = y(:, j + round(sum(f(:, order:-1:1 .* ...
x(:, (jj - 1:-1:(jj - order, 2;
end
x = x(:, order + 1:end; % Remove left padding
x=x';
总程序:
f=imread('Fig0807(c(Aligned.tif';
e=mat2lpc2(f;
figure,imshow(mat2gray(e;
h=entropy(e;
c=lpc2mat2(e;
figure,imshow(c,[];
rmse=compare(f,c;
实验三:
i=imread('Fig0804(a(Tracy.tif';
i=im2double(i;
mask1=[1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ];
mask2=[1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ];
T=dctmtx(16;
B=blkproc(i,[16 16],'P1*x*P2',T,T'; i1=blkproc(B,[16 16],'P1.*x',mask1; i2=blkproc(B,[16 16],'P1.*x',mask2; ii1=blkproc(i1,[16 16],'P1*x*P2',T',T;
ii2=blkproc(i2,[16 16],'P1*x*P2',T',T; figure,imshow(ii1;
figure,imshow(ii2;。