3. 带你入门MATLAB图像处理常用技巧(matlab程序)

您所在的位置:网站首页 matlab程序翻译器 3. 带你入门MATLAB图像处理常用技巧(matlab程序)

3. 带你入门MATLAB图像处理常用技巧(matlab程序)

2023-07-10 06:35| 来源: 网络整理| 查看: 265

   学习目标:学习常用的图像处理技巧

代码及运行结果

改变图像的大小 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);

73257b670402408aa1bdade8bf798656.png

3afd15ac7da34e52aea6847829125702.png

%%  图像的剪切  获取图像的一部分  矩形切割 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);

 23437f283a854b499d9de708e3d60889.png

 dfec031ea8354988afd13201305a9c12.png

 %%  实现图像的旋转 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]);

10e4893d9345485eac73f64dd96199fa.png

 %%  绘制灰度图像的直方图 clear all; close all; I=imread('pout.tif'); subplot(121); imshow(I); subplot(122); imhist(I);     %集中部分可以反映图像清晰程度 set(gcf,'position',[400,400,600,600]);

0e39b29167e841ea816e89ba0d0c0649.png

 %%  图像的对比度增强 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]);

147db3077e914a77b028e07dc5fde2c2.png

 %% 对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]);

bb83100a290c43039dca2a7e0a4904ac.png

 %%  添加噪声 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');

02dd2cfc033c4209b4e8526e90ba27dd.png

%%  图像的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