- 17
- 0
- 约6.75千字
- 约 11页
- 2017-08-21 发布于云南
- 举报
数字图像处理实验报告
班 级:
姓 名:
学 号:
彩图像cat.bmp 灰度图像cat1.bmp
一、应用MATLAB语言编写显示一幅灰度图像、二值图像、索引图像及彩色图像的程序,并进行相互之间的转换
灰度图像I转换成索引图像X,二值图像A,并显示
I=imread(C:\Documents and Settings\Administrator\桌面\图像实验\cat1.bmp);
[X,map]=gray2ind(I,144); %指定灰度级为144,转换成索引图像
A=im2bw(I); %转换成二值图像A
subplot(131);imshow(I); title(原始图像); %显示图像
subplot(132);imshow(X); title(索引图像);
subplot(133);imshow(A) ;title(二值图像)
2、彩图B分别转换为灰度图像I,索引图像X,二值图像A,并显示
B=imread(C:\Documents and Settings\Administrator\桌面\图像实验\cat.bmp);
I=rgb2gray(B);
[X,map]=rgb2ind(B);
A=im2bw(B);
subplot(141);imshow(B); title(原始图像);
subplot(142);imshow(I); title(灰度图像);
subplot(143);imshow(X); title(索引图像);
subplot(144);imshow(A);title(二值图像);
3、索引图像X转换成灰度图像I和二值图像A,并显示
I=imread(C:\Documents and Settings\Administrator\桌面\图像实验\cat1.bmp);
[X,map]=gray2ind(I,144); %将读入的灰度图像转换成索引图像
H=ind2gray(X,map); %索引图像到灰度图像
A=im2bw(X,map); %索引图像到二值图像
subplot(131);imshow(X); title(索引图像); %显示图像
subplot(132);imshow(H); title(灰度图像);
subplot(133);imshow(A) ;title(二值图像)
二、应用MATLAB工具箱演示一幅图像的傅里叶变换、离散余弦变换,观察其频谱图。然后将它们进行逆变换,观察逆变换后的图像
1、傅里叶变换(FFT)
B=imread(C:\Documents and Settings\Administrator\桌面\图像实验\cat.bmp);
B=rgb2gray(B);
F=fftshift(fft2(B));
subplot(131);imshow(B);title(原图像); %原图像
subplot(132);imshow(F);title(FFT变换); %FFT变换后
subplot(133);imshow(log(abs(F)),[]);title(FFT变换频谱); %FFT变换频谱
离散余弦变换(DCT)及频谱
B=imread(C:\Documents and Settings\Administrator\桌面\图像实验\cat.bmp);
GRAY=rgb2gray(B);
D=dct2(GRAY);
subplot(141);imshow(B);title(原图像);
subplot(142);imshow(GRAY);title(灰度图像);
subplot(143);imshow(D);title(DCT变换);
subplot(144);imshow(log(abs(D)),[]);title(DCT变换频谱);
逆变换
傅里叶逆变换
F1=ifft2(F);
subplot(121);imshow(F);title(FFT变换);
subplot(122);imshow(F1);title(FFT逆变换);
离散余弦逆变换
D1=idct2(D);
subplot(121);imshow(D);title(DCT变换);
subplot(122);imshow(D1,[0 255]);title(DCT逆变换);
三、应用MATLAB语言编程来实现一幅图像的增强
1、取一幅灰度图像,对其进行线性点运算,即 ,取(α,β)分别为(1.5,1.2)、(0.7,1.2),对原图像进行线性处理,观察处理后的结果,并分析直方图的变化。
答:①处理前原图像及其直方图
s
原创力文档

文档评论(0)