4. Matlab图像处理(1)

  • 格式:pdf
  • 大小:593.61 KB
  • 文档页数:11



图像的格式转换
im2bw(I,LEVEL); 阈值法从灰度图、RGB图创建二值图。 LEVEL为指定的阈值;(0,1)。

rgb2gray; % 从RGB图创建灰度图,存储类型不变。 im2uint8 % 将图像转换成uint8类型 im2double % 将图像转换成double类型
Thank You!




B=imrotate(A,angle,method,’crop’); angle为旋转角度,正值为逆时针旋转。可 选参数method为imrotate函数指定插值方法。 ‘crop’选项会裁减旋转后增大的图像, 保持和原图像同样大小。 A=imread('nir.bmp'); B=imrotate(A,30,'nearest','crop'); figure;imshow(B);imwrite(B,‘B.bmp');

讲图像之前,先说几个常用函数:
plot plot(x,y,options) 例: x=0:0.1:10; y=cos(x); plot(x,y,'r*');
subplot subplot(m,n域上显示当前图。
例: x=0:0.1:10; y=cos(x); z=sin(x); subplot(2,1,1); plot(x,y,'r*'); subplot(2,1,2); plot(x,z,’b+’);

figure; %创建一个新的窗口
例: x=0:0.1:10; y=cos(x); plot(x,y,'r*');
z=sin(x); figure; plot(x,z,’b^’);


图像的读取 A=imread(FILENAME,FMT)
例: im=imread('D:\1.BMP'); %读入图像


图像的写入 imwrite(A,FILENAME,FMT)
例: imwrite(im,‘zz.bmp');



图像的显示 imshow(I,[low high]) I为要显示的图像矩阵。[low high]为指定显 示灰度图像的灰度范围。高于high的像素被 显示成白色;低于low的像素被显示成黑色; 介于 High和low之间的像素被按比例拉伸后显示 为各种等级的灰色。