3. 带你入门MATLAB图像处理常用技巧(matlab程序) |
您所在的位置:网站首页 › matlab程序翻译器 › 3. 带你入门MATLAB图像处理常用技巧(matlab程序) |
学习目标:学习常用的图像处理技巧 代码及运行结果改变图像的大小 clear all; close all; [X,map]=imread('trees.tif','tif'); %读取索引图像 [Y,newmap]=imresize(X,map,0.2); %改成五分之一大小 figure; subimage(X,map); figure; subimage(Y,newmap); %% 图像的剪切 获取图像的一部分 矩形切割 clear all; close all; I=imread('trees.tif','tif'); J=imcrop(I,[20,20,100,100]); %矩形的原点是20,20 大小是100*100 figure; imshow(I); figure; imshow(J);
%% 实现图像的旋转 clear all; close all; A=imread('trees.tif','tif'); B=imrotate(A,-90,'nearest'); %顺时针旋转90度 figure; subplot(121); imshow(A); subplot(122); imshow(B) set(gcf,'position',[300,300,600,400]); %% 绘制灰度图像的直方图 clear all; close all; I=imread('pout.tif'); subplot(121); imshow(I); subplot(122); imhist(I); %集中部分可以反映图像清晰程度 set(gcf,'position',[400,400,600,600]); %% 图像的对比度增强 clear all; close all; I=imread('pout.tif'); J=imadjust(I,[0.3 0.7],[]); %对比度范围发生变化,0.3到0.7变成 0到1之间 subplot(121); subimage(I); subplot(122); subimage(J); set(gcf,'position',[400,400,600,500]); %% 对RGB图像进行增强 clear all; close all; RGB1=imread('peppers.png'); RGB2=imadjust(RGB1,[0.2 .3 0; .6 .7 1],[]); subplot(121); subimage(RGB1); subplot(122); subimage(RGB2); set(gcf,'position',[400,400,600,500]); %% 添加噪声 clear all,close all; I=imread('trees.tif','tif'); J1=imnoise(I,'gaussian',0.1); %高斯噪声 J2=imnoise(I,'poisson'); %泊松噪声 J3=imnoise(I,'salt & pepper',0.1); %椒盐噪声 figure; subplot(221),imshow(I),title('原图像') subplot(222),imshow(J1),title('Gaussian') subplot(223),imshow(J2),title('Poisson') subplot(224),imshow(J3),title('Salt & Pepper'); %% 图像的DCT 离散余弦变换 常用来做图像压缩 clear all; close all; RGB=imread('peppers.png'); %读取一个RGB的图像 注意 I=rgb2gray(RGB); J=dct2(I); %图像的DCT 离散余弦变换 figure; imshow(log(abs(J)),[]),colormap(jet),colorbar; J(abs(J) |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |