数字图像处理实验程序MATLAB_第1页
数字图像处理实验程序MATLAB_第2页
数字图像处理实验程序MATLAB_第3页
数字图像处理实验程序MATLAB_第4页
数字图像处理实验程序MATLAB_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实验一内容(一(1彩色图像变灰度图像A=imread('1.jpg'B=rgb2gray(A;figuresubplot(1,2,1,imshow(Atitle('原图'subplot(1,2,2,imshow(Btitle('原图灰度图像'(2彩色图像变索引图像A=imread('1.jpg'figuresubplot(1,2,1,imshow(Atitle('原图'X,map=rgb2ind(A,128;subplot(1,2,2,imshow(X,maptitle('原图索引图像'(3彩色图像

2、变二值图像A=imread('1.jpg'figuresubplot(1,2,1,imshow(Atitle('原图'C=im2bw(A,0.2;subplot(1,2,2,imshow(Ctitle('原图二值图像'(4灰度图像变索引图像(一A=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度图像'C=grayslice(B,39;subplot(1,2,2,imshow(Ctitle('灰度变索引图像'(5灰度图像变

3、索引图像(二A=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度图像'X,map=gray2ind(B,63;subplot(1,2,2,imshow(X,maptitle('灰度变索引图像'(6灰度图像变彩色图像A=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度图像'C=gray2rgb(B,map;subplot(1,2,2,imshow(Ctitle

4、('灰度变彩色图像'内容(二(1灰度平均值A=imread('1.jpg'figureB=rgb2gray(A;subplot(1,2,1,imshow(Btitle('灰度图像'B=double(B;m,n=size(B;sumg=0.0;for i=1:m;for j=1:n;sumg=sumg+B(i,j;endendavg=sumg/(m*n % 均值maxg=max(max(B % 区域最大灰度ming=min(min(B % 区域最小灰度(2彩色平均值figureimshow(Atitle('彩色图像'A=double

5、(A;m,n=size(A;sumg=0.0;for i=1:m;for j=1:n;sumg=sumg+A(i,j;endendavg=sumg/(m*nsqure=m*nmaxg=max(max(Aming=min(min(A内容(三采样量化实验二图像变换傅里叶变换、反变换、I=imread('19.jpg'A=rgb2gray(I;x1=fft2(A;x2=fftshift(x1;x3=ifft(x1/10;figure,subplot(1,4,1;imshow(Atitle('原图'subplot(1,4,2;imshow(x1title('频谱

6、图'subplot(1,4,3;imshow(log(abs(x2+1,0 10;title('直流分量移至频谱图中心'subplot(1,4,4;imshow(x3,0 10title('傅里叶反变换'DCT变换、反变换I=rgb2gray(X;subplot(1,3,1;imshow(I;title('原图'subplot(1,3,2;J=dct2(I;imshow(log(abs(J,0 20;title('二维离散余弦变换'subplot(1,3,3;K=idct2(J/20;imshow(K,0 20;title

7、('二维离散反余弦变换'利用DCT变换压缩图像I=imread('19.jpg'A=rgb2gray(I;B=DCT2(A;B(abs(B<0.1=0;C=idct2(B/255;figure,subplot(1,3,1;imshow(A;title('原图'subplot(1,3,2;imshow(B;title('二维离散余弦变换频谱图'subplot(1,3,3;imshow(C;title('压缩后图像'实验三图像增强(一灰度图像增强(1线性变换法clc;clear all;I=imread('

8、;19.jpg'A=rgb2gray(I;colormap;imshow(A;%设置图像倒数参数j=imadjust(A,0 1,1 0,1.5;figure;subimage(j(2灰度图像的非线性变换(之对数 I=imread('19.jpg'colormapimshow(IJ=double(I;J=45*log(J+1;I=uint8(J;figure,subimage(J(二直方图校正直方图均衡I=imread('19.jpg'B=rgb2gray(I;imshow(B,40 255;figure,imhist(Btitle('直方图&#

9、39;J=imadjust(B,0.15 0.9,0 1; figure,imhist(B,64title('均衡直方图'滤波I=imread('19.jpg'figure,B=rgb2gray(I;C=imnoise(B,'salt & pepper',0.02;D=imfilter(B,fspecial('average',3; E=medfilt2(B;subplot(1,3,2imshow(Dtitle('均值滤波'subplot(1,3,3imshow(Dtitle('中值滤波's

10、ubplot(1,3,1imshow(Ctitle('加入椒盐噪声图像'锐化处理I=imread('19.jpg'A=rgb2gray(I;figure,subplot(2,3,1,imshow(A;title('原图' hs=fspecial('sobel' S=imfilter(A,hs; hp=fspecial('prewitt' P=imfilter(A,hs; A=double(A;%双精度型 H=0 1 0,1 -4 1,0 1 0;%拉普拉斯算子 J=conv2(A,H,'same'

11、K=A-J; subplot(2,3,2,imshow(K; title('拉普拉斯锐化图像' B=edge(A,'roberts',0.1; subplot(2,3,3,imshow(B; title('罗伯特锐化图像' subplot(2,3,4,imshow(S; title('sobel算子锐化图像' subplot(2,3,5,imshow(P; title('prewitt算子锐化图像' 实验四 放缩 A=imread('19.jpg' imshow(A; title('原图&#

12、39; B=imresize(A,2 figure, imshow(B; title('二倍图' C=imresize(A,0.5 figure imshow(C title('二分之一图' 旋转 A=imread('19.jpg' figure subplot(1,4,1, imshow(A; title('原图像' B=imrotate(A,30,'nearest' subplot(1,4,2, imshow(uint8(B; title('旋转30度图像' C=imrotate(A,45,&#

13、39;nearest' subplot(1,4,3, imshow(uint8(C; title('旋转45度图像' D=imrotate(A,60,'nearest' subplot(1,4,4, imshow(uint8(D; title('旋转60度图像' 镜像 A1=imread('19.jpg' A1=double(A1; Figure, subplot(1,4,1, imshow(uint8(A1; H=size(A1; title('原像' A2(1:H(1,1:H(2,1:H(3=A1(H(

14、1:-1:1,1:H(2,1:H(3;%垂直镜像 subplot(1,4,2, imshow(uint8(A2; title('垂直镜像' A3(1:H(1,1:H(2,1:H(3=A1(1:H(1,H(2:-1:1,1:H(3;%水平镜像 subplot(1,4,3, imshow(uint8(A3; title('水平镜像' A4(1:H(1,1:H(2,1:H(3=A1(H(1:-1:1,H(2:-1:1,1:H(3;%对角镜像 subplot(1,4,4, imshow(uint8(A4; title('对角镜像' 剪切 A1=imrea

15、d('19.jpg' A2=imcrop(A1,75 68 100 110; figure subplot(1,2,1, imshow(A1; title('原像' subplot(1,2,2, imshow(A2; title('剪切后像' 实验五 阈值分割 A=imread('19.jpg' figure subplot(1,4,1, imshow(A; title('原图像' B=im2bw(A,91/255; subplot(1,4,2, imshow(B; title('阈值91的图像' C=im2bw(A,71/255; subplot(1,4,3, imshow(C; title('阈值71的图像' D=im2bw(A,140/255; subplot(1,4,4, imshow(D; title('阈值140的图像' 边缘检测 I=imread('19.jpg' A=rgb2gray(I; figure subplot(1,4,1, imshow(A; title('原图像' B=edge(A,'sobe

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论