数据图像处理报告.docx
- 文档编号:12341182
- 上传时间:2023-04-18
- 格式:DOCX
- 页数:36
- 大小:1.64MB
数据图像处理报告.docx
《数据图像处理报告.docx》由会员分享,可在线阅读,更多相关《数据图像处理报告.docx(36页珍藏版)》请在冰豆网上搜索。
数据图像处理报告
数字图像处理实验报告
学院:
学号:
班号序号:
姓名:
指导老师:
目录
1.实验题目及问题分析
1.实验一
(1)题目·····························································4
(2)源程序···························································4
(3)运行结果·························································4
(4)问题分析·························································4
2.实验二
(1)题目·····························································4
(2)源程序···························································4
(3)运行结果·························································5
(4)问题分析·························································6
3.实验三
(1)题目·····························································6
(2)源程序···························································6
(3)运行结果·························································6
(4)问题分析·························································6
4.实验四
(1)题目·····························································7
(2)源程序···························································7
(3)运行结果·························································8
(4)问题分析·························································9
5.实验五
(1)题目·····························································10
(2)源程序···························································10
(3)运行结果·························································10
(4)问题分析·························································11
6.实验六
(1)题目·····························································11
(2)源程序···························································11
(3)运行结果·························································13
(4)问题分析·························································14
7.实验七
(1)题目·····························································15
(2)源程序···························································15
(3)运行结果·························································16
(4)问题分析·························································17
8.实验八
(1)题目·····························································17
(2)源程序···························································17
(3)运行结果·························································19
(4)问题分析·························································20
9.实验九
(1)题目·····························································20
(2)源程序···························································20
(3)运行结果·························································21
(4)问题分析·························································21
10.实验十
(1)题目·····························································21
(2)源程序···························································21
(3)运行结果·························································23
(4)问题分析·························································25
2.我的收获及心得体会··········································25
三.参考文献·······················································26
1、实验题目及问题分析
1.实验一
(1)题目
编程实现打开一个灰度图像,能够显示图像。
(2)源程序
a=imread('F:
wuhao.jpg');%读取图像文件
b=rgb2gray(a);%将真彩色图像转换为灰度图像
figure
(1);
imshow(a)%显示图像
figure
(2);
imshow(b);
(3)运行结果
原图灰度图
(4)问题分析
结果运行符合要求
2.实验二
(1)题目
用灰度图形式表示彩色图象,分别显示1幅彩色图象的R,G,B分量(每个分量用8bit表示),和这幅彩色图象的H,S,I分量(每个分量也各用8bit表示)。
(2)源程序
clearall;
%显示1幅彩色图象的R,G,B分量
a=imread('F:
wuhao.jpg');
%提取三维数据的第n维数据
R=a(:
:
1);%提取三维数据的第1维数据,即红色
G=a(:
:
2);%提取三维数据的第1维数据,即绿色
B=a(:
:
3);%提取三维数据的第1维数据,即蓝色
figure
(1)
subplot(2,2,1)
imshow(a);
title('原始图像');
subplot(2,2,2);
imshow(R);
title('R分量图像');
subplot(2,2,3);
imshow(G);
title('G分量图像');
subplot(2,2,4);
imshow(B);
title('B分量图像');
%显示1幅灰度图象的H,S,I分量
clearall;
a=imread('F:
wuhao.jpg');
HSI=rgb2hsi(a);
H=HSI(:
:
1);
S=HSI(:
:
2);
I=HSI(:
:
3);
figure
(2)
subplot(2,2,1);
imshow(H);
title('H分量图像')
subplot(2,2,2);
imshow(S);
title('S分量图像')
subplot(2,2,3);
imshow(I);
title('I分量图像');
(3)运行结果
(4)问题分析
结果运行符合要求
3.实验三
(1)题目
编程实现图像傅立叶变换
(2)源程序
clearall
a=imread('F:
wuhao.jpg');
b=rgb2gray(a);
figure
(1);
imshow(b);
title('原始图像');
F=fft2(b);%对图片进行傅立叶变换
F2=abs(fftshift(F));%fftshift将零频点移到频谱的中间
figure
(2);
imshow(log(F2),[]),colormap(jet(64)),colorbar;%[]这个参数直接写成“[]”的时候是指[min,max],用指定的灰度范围[minmax]显示灰度图像,colormap(jet(64)生成了64种从黑到白的渐变色,
title('傅里叶变换结果');
(3)运行结果
(4)问题分析
运行结果符合题目要求,代码中使用了imshow(log(F2),[]),colormap(jet(64)),colorbar;代码,该代码的可以产生一个渐变色范围进行对照,使运行结果图看起来更加美观。
4.实验四
(1)题目
用直接灰度变换改变图像(求反,增强对比度,动态范围压缩,灰度切分)
(2)源程序
clc;
clear;
W=rgb2gray(imread('F:
wuhao.jpg'));
[mn]=size(W);%表示W矩阵的大小(行*列),m是行数,n是列数
figure
(1);
subplot(2,3,1),imshow(W);
%%**************取反************
qf=255-W;
%qf(i,j)=255-W(i,j);
subplot(2,3,4),imshow(uint8(qf));title('取反');%imshow(uint8(qf))按照256级灰度显示qf得绝对数据。
0表示0,255表示255,大于255得都是255
%*************灰度增强*************
X=[030180255];
Y=[0120230255];
subplot(2,3,2),plot(X,Y);
fori=1:
m
forj=1:
n
ifW(i,j)<31
zq(i,j)=W(i,j)*(120/30);
end
if(W(i,j)>30)&&(W(i,j)<181)
zq(i,j)=W(i,j)*((230-120)/(180-30))+120;
end
ifW(i,j)>180
zq(i,j)=W(i,j)*((255-230)/(255-180))+230;
end
end
end
subplot(2,3,3),imshow((zq));title('灰度增强');
%%%***********动态范围压缩***********
figure
(1);
W1=im2double(W);%把图像数据类型转换为双精度浮点类型。
A=30.6;
fori=1:
m
forj=1:
n
ifW1(i,j)<1/A
ys(i,j)=A*W1(i,j)/(1+log(A));
else
ys(i,j)=(1+log(A*W1(i,j)))/(1+log(A));
end
end
end
subplot(2,3,5),imshow(ys);title('动态范围压缩');
%%%***********灰度切分***********
min=100;
max=130;
hdqf=W;
fori=1:
m
forj=1:
n
if(W(i,j)<=max)&&(W(i,j)>=min)
hdqf(i,j)=140;
end
end
end
subplot(2,3,6),imshow((hdqf));title('灰度切分');
(3)运行结果
(4)问题分析
在进行检验的时候,老师说只有灰度增强的坐标图,最好加上其它的坐标图,于是,在检验后,我又加了如下代码:
X=[0255]
Y=[2550]
subplot(2,2,1);
plot(X,Y)
title('求反')
A=30.6;
W1=0:
255;
ys=(1+log(A*W1))/(1+log(A));
ys=ys/ys(256)*255;
subplot(2,2,2)
plot(W1,ys)
title('动态范围压缩')
X=[0100101129130255]
Y=[0100140140130255]
subplot(223)
plot(X,Y)
title('灰度切分')
运行结果显示
加上这些代码,在配合原图一起,这样就可以把其它要求的内容用坐标形式显示出来了。
5.实验五
(1)题目
做出直方图,进行直方图均衡化。
(2)源程序
clearall
a=imread('F:
wuhao.jpg');
I=rgb2gray(a);%进行灰度处理
J=histeq(I);%直方图均衡化,指定均衡化后的灰度级数为64(缺省值为64)
subplot(2,2,1);
imshow(I);
title('原始图像');
subplot(2,2,2);
imhist(I);%该函数用于获取图像数据直方图,
title('原始图像直方图');
axis([0255015000]);
subplot(2,2,3);
imshow(J);%获取图像
title('均衡化后的图像');
subplot(2,2,4);
imhist(J);%获取直方图
axis([0255015000]);
title('均衡化后的直方图');
(3)运行结果
(4)问题分析
运行结果符合要求
6.实验六
(1)题目
用空域和频域滤波器,对图像进行平滑,并比较两种方法得到图像质量。
(2)源代码
clearall
RGB=imread('F:
wuhao.jpg');
I=rgb2gray(RGB);
H1=ones(3)/9;
J=imnoise(I,'gaussian',0,0.02);%添加高斯白噪声
J=double(J);
G1=conv2(J,H1,'same');%3*3均值低通滤波进行平滑
figure
(1)
subplot(221);
imshow(I);
title('原始图像');
subplot(222);
imshow(J,[]);
title('添加高斯噪声图像');
subplot(223);
imshow(G1,[]);
title('3*3均值滤波图像');
clearall
RGB=imread('F:
wuhao.jpg');
I=rgb2gray(RGB);
J=imnoise(I,'gaussian');
J=double(J);
D1=15;
D2=30;
D3=50;
D4=80;
Fuv=fftshift(fft2(J));%将灰度图像的二维不连续Fourier变换的零频率成分移到频谱的中心
[M,N]=size(Fuv);%分别返回Fuv的行数到M中,列数到N中
xo=floor(M/2);%向下取整
yo=floor(N/2);
fori=1:
M
forj=1:
N
D=sqrt((i-xo)^2+(j-yo)^2);%点(i,j)到傅立叶变换中心的距离
if(D>=D1)%点(i,j)在通带内的情况
h1(i,j)=0;
else%点(i,j)在阻带内的情况
h1(i,j)=1;
end
if(D>=D2)
h2(i,j)=0;
else
h2(i,j)=1;
end
if(D>=D3)
h3(i,j)=0;
else
h3(i,j)=1;
end
if(D>=D4)
h4(i,j)=0;
else
h4(i,j)=1;
end
end
end
Guv1=h1.*Fuv;%ILPF滤波后的频域表示
Guv2=h2.*Fuv;
Guv3=h3.*Fuv;
Guv4=h4.*Fuv;
g1=ifftshift(Guv1);%对s进行反FFT移动
g1=uint8(real(ifft2(g1)));%对s进行二维反离散的Fourier变换后,取复数的实部转化为无符号8位整数
g2=ifftshift(Guv2);
g2=uint8(real(ifft2(g2)));
g3=ifftshift(Guv3);
g3=uint8(real(ifft2(g3)));
g4=ifftshift(Guv4);
g4=uint8(real(ifft2(g4)));
figure
(2)
subplot(231);
imshow(I);
title('原始图像');
subplot(232);
imshow(J,[]);
title('噪声图像');
subplot(233);
imshow(g1);
title('ILPFD0=15');%d0截止频率
subplot(234);
imshow(g2);
title('ILPFD0=30');
subplot(235);
imshow(g3);
title('ILPFD0=50');
subplot(236);
imshow(I);%CUOWU
title('ILPFD0=80');
(3)运行结果
(4)问题分析
这个题目的运行结果最后一个是错误的,就是ILPFD0=80的运行结果不应该那么清晰,应该有很多噪声点才对。
经过对代码进行分析发现,最后几行代码subplot(236);imshow(I);%CUOWUtitle('ILPFD0=80');的显示中imshow(I)显示的是原图,这属于代码编写错误,经过纠正可以要改为imshow(g4),经运行结果符合要求,运行结果如下
7.实验七
(1)题目
用空域和频域滤波器,对图像进行锐化,并比较两种方法得到图像质量。
(2)源代码
clearall
RGB=imread('F:
wuhao.jpg');
I=rgb2gray(RGB);
subplot(121);
imshow(I);
title('原始图像');
I=double(I);
H=[0-10
-15-1
0-10];%锐化模板
J=conv2(I,H,'same');
figure
(1)
subplot(122);
imshow(J,[]);
title('空域锐化后图像');
RGB=imread('F:
wuhao.jpg');
I=rgb2gray(RGB);
J=double(I);
D1=15;
D2=30;
D3=50;
Fuv=fftshift(fft2(J));
[M,N]=size(Fuv);
xo=floor(M/2);
yo=floor(N/2);
fori=1:
M
forj=1:
N
D=sqrt((i-xo)^2+(j-yo)^2);
if(D>=D1)
h1(i,j)=1;
else
h1(i,j)=0;
end
if(D>=D2)
h2(i,j)=1;
else
h2(i,j)=0;
end
if(D>=D3)
h3(i,j)=1;
else
h3(i,j)=0;
end
end
end
Guv1=h1.*Fuv;
Guv2=h2.*Fuv;
Guv3=h3.*Fuv;
g1=ifftshift(Guv1);
g1=uint8(real(ifft2(g1)));
g2=ifftshift(Guv2);
g2=uint8(real(ifft2(g2)));
g3=ifftshift(Guv3);
g3=uint8(real(ifft2(g3)));
figure
(2)
subplot(131);
imshow(g1);
title('IHPFD0=15');
subplot(132);
imshow(g2);
title('IHPFD0=30');
subplot(133);
imshow(g3);
title('IHPFD0=50');
(3)运行结果
(4)问题分析
运行结果符合要求
8.实验八
(1)题目
选用两种压缩算法,对图像进行压缩。
并比较这两种算法。
(2)源代码
clearall
%保留低频系数法进行图像压缩
loadwbarb
figure
(1)
subplot(221);
image(X);
colormap(map);
axissquare;
title('原始图像');
disp('原始图像大小');%disp显示矩阵和文字内容
whos('X');%whos列出工作内存中的变量细节
%对图像小波分解
[c,l]=wavedec2(X,2,'bior3.7');
%提取第一层的低频和高频系数
cA1=appcoef2(c,l,'bior3.7',1);%appcoef2提取二维信号小波分解的近似系数,从多级小波分解结构[c,l]中提取第1级的近似系数
cH1=detcoef2('h',c,l,1);%detcoef2提取二维信号小波分解的细节系数,从多级小波分解结构[c,l]中提取第1级的水平的细节系数
cD1=detcoef2('d',c,l,1);%detcoef2提取二维信号小波分解的细节系数,从多级小波分解结构[c,l]中提取第1级的垂直的细节系数
cV1=detcoef2('v',c,l,1);%detcoef2提取二维信号小波分解的细节系数
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据 图像 处理 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)