何清波 博士 副教授 中国科学技术大学 精密机械与精密仪器系 安徽合肥 Email:qbhe@ustc.edu.cn 电话: 3607985 中国科学技术大学研究生课程 (PI05302) 数字图像处理 何清波 博士 副教授 中国科学技术大学 精密机械与精密仪器系 安徽合肥 Email:qbhe@ustc.edu.cn 电话: 3607985
The MATLAB Image Processing Toolbox The Image Processing Toolbox is a collection of MATLAB functions (called M-functions or M-files) that extend the capability of the MATLAB environment for the solution of digital image processing problems.
The MATLAB Image Processing Toolbox Including: -Spatial image transformations -Morphological operations -Neighborhood and block operations -Linear filtering and filter design -Transforms - Image analysis and enhancement -Image registration -Deblurring -Region of interest operations
How do I know M-function? Find it in Matlab Help. -by category. -by alphabetical order. Find it on the textbook.
Matlab 内建图像 C:\MATLAB7\toolbox\images\imdemos 皆为Matlab Help中范例的原始图像。 使用时只需直接在指令中输入文件名,即可使用。 适用于观察影像处理结果
Reading an image imread() 功用:将图像加载并存成array格式备用 用法:[I,map] = imread(filename); I = imread(filename); ex: I = imread ('pout.tif'); I为指向影像的变量 不指定变数,则为ans
Displaying an image imshow() 功用:开启一个窗口显示影像 用法: imshow(I) imshow(I,map) Figure, imshow() 功用:开启一个新窗口显示影像 用法: figure,imshow(I)
Displaying an image(cont.) imshow(I, [low, high]) imshow(I, [ ]) 功用:displays I as a grayscale intensity image, specifying the data range for I. The minimum value in I is displayed as black, and the maximum value is displayed as white. Low =100 High=200
Displaying an image(cont.) Spatial domain
Displaying an image(cont.) pixval : 功能:cursor on image to show pixel values 用法: imshow(I),pixval (impixelinfo in V7.8 or R2009a)
Displaying an image(cont.) colorbar 功能:To display an image with a colorbar that indicates the range of intensity values. 用法: imshow(I), colorbar ex: I = imread('pout.tif'); imshow(I) , colorbar
Writing an image imwrite() 功能: Write image to graphics file. 用法: imwrite(I,filename,format) ex: imwrite(I,'pout.jpg‘,’JPEG’); Note that ‘I’ should be uint8 format If not, ‘I’ should be written as uint8(I).
Image information Image size: size() ex: I= imread('saturn.png'); size(I) [M,N] = size(I) M=Height of image I N=Width of image I
Image information whos 功用:display information about an image . ex: whos I Imfinfo( filename ) 功用: display information about image file . ex: info = imfinfo('saturn.png') Name Size Bytes Class Attributes I 291x240 69840 uint8
Digital Image processing 图像二值化 g = im2bw(I, T); 功用:Convert intensity image I to binary image g using threshold T, where T must be in range [0, 1]. ex: I= imread('pout.tif'); g = im2bw(I, 0.4); imshow(g) ,colorbar
Digital Image processing(cont.) 彩色转灰阶 rgb2gray() 功用:将RBG彩色影像转换成gray-level影像。 ex: I= imread ('saturn.png'); g = rgb2gray(I); imshow(g), colorbar
Digital Image processing(cont.) 反相 imcomplement( ) 功用:The negative of an image. ex: J = imcomplement(g); imshow(J),
Digital Image processing(cont.) 变更影像大小 imresize(I,scale,method); 功用:To change the size of an image. interpolation Method: -'nearest‘ :Nearest-neighbor interpolation -'bilinear‘ :Bilinear (the default) -'bicubic‘ :Bicubic interpolation
Digital Image processing(cont.) ex: I = imread('circuit.tif'); J = imresize(I,1.25); imshow(I) figure, imshow(J)
Digital Image processing(cont.) ex: I = imread('circuit.tif'); J = imresize(I,[100 150], 'bilinear'); imshow(I) figure, imshow(J)
Digital Image processing(cont.) 旋转影像 imrotate(I, angle); 功用:To rotate an image. ex: I = imread('pout.tif'); J = imrotate(I,35); imshow(J)
More Example I=imread('cameraman.tif'); Using affine transformation 1.Rotation 45 degree I=imread('cameraman.tif'); T = maketform('affine',[cosd(45) -sind(45) 0; sind(45) cosd(45) 0; 0 0 1]); tformfwd([10 20],T); I2 = imtransform(I,T); imshow(I2)
More Example(cont.) 2.Translation I = imread('cameraman.tif'); se = translate(strel(1), [25 25]); J = imdilate(I,se); imshow(I), title('Original') figure, imshow(J), title('Translated');
More Example(cont.) 3.shear I=imread('cameraman.tif'); T = maketform('affine',[1 0 0; 1 2 0; 0 0 1]); tformfwd([10 20],T); I2 = imtransform(I,T); imshow(I2)
结束! Note 一定要学会使用help命令 一定要适应采用M文件编程 一定要熟练掌握矩阵的操作