some functions of matlab used for digital images processing

来源:互联网 发布:软件代理招商方案 编辑:程序博客网 时间:2024/06/06 18:56

1、图像的变换

① fft2:fft2函数用于数字图像的二维傅立叶变换,如:i=imread(‘104_8.tif’);

j=fft2(i);

②ifft2::ifft2函数用于数字图像的二维傅立叶反变换,如:

i=imread(‘104_8.tif’);

j=fft2(i);

k=ifft2(j);

2、模拟噪声生成函数和预定义滤波器

① imnoise:用于对图像生成模拟噪声,如:

i=imread(‘104_8.tif’);

j=imnoise(i,’gaussian’,0,0.02);%模拟高斯噪声

② fspecial:用于产生预定义滤波器,如:

h=fspecial(‘sobel’);%sobel水平边缘增强滤波器

h=fspecial(‘gaussian’);%高斯低通滤波器

h=fspecial(‘laplacian’);%拉普拉斯滤波器

h=fspecial(‘log’);%高斯拉普拉斯(LoG)滤波器

h=fspecial(‘average’);%均值滤波器

2、图像的增强

①直方图:imhist函数用于数字图像的直方图显示,如:

i=imread(‘104_8.tif’);

imhist(i);

②直方图均化:histeq函数用于数字图像的直方图均化,如:

i=imread(‘104_8.tif’);

j=histeq(i);

③对比度调整:imadjust函数用于数字图像的对比度调整,如:i=imread(‘104_8.tif’);

j=imadjust(i,[0.3,0.7],[]);

④对数变换:log函数用于数字图像的对数变换,如:

i=imread(‘104_8.tif’);

j=double(i);

k=log(j);

⑤基于卷积的图像滤波函数:filter2函数用于图像滤波,如:i=imread(‘104_8.tif’);

h=[1,2,1;0,0,0;-1,-2,-1];

j=filter2(h,i);

⑥线性滤波:利用二维卷积conv2滤波, 如:

i=imread(‘104_8.tif’);

h=[1,1,1;1,1,1;1,1,1];

h=h/9;

j=conv2(i,h);

⑦中值滤波:medfilt2函数用于图像的中值滤波,如:

i=imread(‘104_8.tif’);

j=medfilt2(i);

⑧锐化

(1)利用Sobel算子锐化图像, 如:

i=imread(‘104_8.tif’);

h=[1,2,1;0,0,0;-1,-2,-1];%Sobel算子

j=filter2(h,i);

(2)利用拉氏算子锐化图像, 如:

i=imread(‘104_8.tif’);

j=double(i);

h=[0,1,0;1,-4,0;0,1,0];%拉氏算子

k=conv2(j,h,’same’);

m=j-k;

3、图像边缘检测

①sobel算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’sobel’,thresh)

②prewitt算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’prewitt’,thresh)

③roberts算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’roberts’,thresh)

④log算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’log’,thresh)

⑤canny算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’canny’,thresh)

⑥Zero-Cross算子 如:

i=imread(‘104_8.tif’);

j = edge(i,’zerocross’,thresh)

4、形态学图像处理

①膨胀:是在二值化图像中“加长”或“变粗”的操作,函数imdilate执行膨胀运算,如:

a=imread(‘104_7.tif’); %输入二值图像

b=[0 1 0;1 1 1;0 1 0];

c=imdilate(a,b);

②腐蚀:函数imerode执行腐蚀,如:

a=imread(‘104_7.tif’); %输入二值图像

b=strel(‘disk’,1);

c=imerode(a,b);

③开运算:先腐蚀后膨胀称为开运算,用imopen来实现,如:

a=imread(‘104_8.tif’);

b=strel(‘square’,2);

c=imopen(a,b);

④闭运算:先膨胀后腐蚀称为闭运算,用imclose来实现,如:

a=imread(‘104_8.tif’);

b=strel(‘square’,2);

c=imclose(a,b);

===========================================================

Matlab 图像处理相关函数命令大全

一、通用函数:

colorbar 显示彩色条

语法:colorbar \ colorbar(‘vert’) \ colorbar(‘horiz’) \ colorbar(h) \ h=colorbar(…) \ colorbar(…,’peer’,axes_handle)

getimage 从坐标轴取得图像数据

语法:A=getimage(h) \ [x,y,A]=getimage(h) \ […,A,flag]=getimage(h) \ […]=getimage

imshow 显示图像

语法:imshow(I,n) \ imshow(I,[low high]) \ imshow(BW) \ imshow(X,map) \ imshow(RGB)\ imshow(…,display_option) \ imshow(x,y,A,…) \ imshow filename \ h=imshow(…)

montage 在矩形框中同时显示多幅图像

语法:montage(I) \ montage(BW) \ montage(X,map) \ montage(RGB) \ h=montage(…)

immovie 创建多帧索引图的电影动画

语法:mov=immovie(X,map) \ mov=immovie(RGB)

subimage 在一副图中显示多个图像

语法:subimage(X,map) \ subimage(I) \ subimage(BW) \ subimage(RGB) \ subimage(x,y,…) \ subimage(…)

truesize 调整图像显示尺寸

语法:truesize(fig,[mrows mcols]) \ truesize(fig)

warp 将图像显示到纹理映射表面

语法:warp(X,map) \ warp(I ,n) \ warp(z,…) warp(x,y,z,…) \ h=warp(…)

zoom 缩放图像

语法:zoom on \ zoom off \ zoom out \ zoom reset \ zoom \ zoom xon \ zoom yon\ zoom(factor) \ zoom(fig,option)

二、图像文件I/O函数命令

imfinfo 返回图形图像文件信息

语法:info=imfinfo(filename,fmt) \ info=imfinfo(filename)

imread 从图像文件中读取(载入)图像

语法:A=imread(filename,fmt) \ [X,map]=imread(filename,fmt) \ […]=imread(filename) \ […]=imread(URL,…) \ […]=imread(…,idx) (CUR,ICO,and TIFF only) \ […]=imread(…,’frames’,idx) (GIF only) \ […]=imread(…,ref) (HDF only) \ […]=imread(…,’BackgroundColor’,BG) (PNG only) \ [A,map,alpha] =imread(…) (ICO,CUR,PNG only)

imwrite 把图像写入(保存)图像文件中

语法:imwrite(A,filename,fmt) \ imwrite(X,map,filename,fmt) \ imwrite(…,filename) \ imwite(…,Param1,Val1,Param2,Val2…)

imcrop 剪切图像

语法:I2=imcrop(I) \ X2=imcrop(X,map) \ RGB2=imcrop(RGB) \ I2=imcrop(I,rect) \ X2=imcrop(RGB,rect) \ […]=imcrop(x,y,…) \ [A,rect]=imcrop(…) \ [x,y,A,rect]=imcrop(…)

imresize 改变图像大小

语法:B=imresize(A,m,method)

imrotate 旋转图像

语法:B=imrotate(A,angle,method) \ B=imrotate(A,angle,method,’crop’)

三、像素和统计处理函数

corr2 计算两个矩形的二维相关系数

语法:r=corr2(A,B)

0 0
原创粉丝点击