图像处理函数查询目录
预处理
读取图像
output = imread('image.png');
显示图像
imshow(output);
查看和浏览图像
图像查看器为显示图像和执行常见的图像处理任务提供集成环境。
imtool(output);
灰度处理
output = rgb2gray(image);
插值运算
# 双线性插值
output = imresize(image,2);
直方图
imhist(image) # 显示直方图
hist = imhist(image); # 获取直方图数据
亮度调节
调整数据以跨越数据范围
output= imadjust(input);
求极值点
# [值,坐标]=(输入,最小波峰,最小点间距离)
[maxv,maxl]=findpeaks(hist,'minpeakheight',30,'minpeakdistance',40);
自适应直方图均衡化
output = adapthisteq(image);
滤波
高斯滤波
# 标准差
sigma = 7;
# 高斯滤波,模板大小,标准差
gausm = fspecial('gaussian',[7 7],sigma);
# replicate 表示边缘复制
output = imfilter(image,gausm,'replicate');
fspecia()
函数用于建立预定义的滤波算子。'average'
时为均值滤波
中值滤波
output = medfilt2(image, [7,7]);
图像分割
Otsu算法
output = imbinarize(image, 'global');
自定义阈值分割
# 二值化,val是阈值+
output = im2bw(image,val);
形态学处理
膨胀
# 生成结构元素
s = strel('disk',para); # para指生成结构元素的大小
output = imdilate(image,s);
腐蚀
output = imerode(image, s);
开运算
output = imopen(image,s);
闭运算
output = imclose(image, s);
顶帽运算
output = imtophat(image, s);
低帽运算
output = imbothat(image, s);
细化
output = bwmorph(image,'thin',para);
'thin’表示进行细化处理,'skel’表示骨骼化
para值细化的程度,取值为1,2, … , inf。 当取inf表示进行极限细化。
填充
output = imfill(image, 'holes');
连通区域
连通区域基本参数获取
output = regionprops(image,'All');
移除小面积连通区域
output = bwareaopen(image, para, 8);
para: 面积阈值下限
标记连通区域
# 连通区域标记,数量
[lable, num4] = bwlabel(image, 4);
清理边框
image2 = imclearborder(image);
imclearborder Suppress light structures connected to image border. IM2 = imclearborder(IM) suppresses structures that are lighter than their surroundings and that are connected to the image border. IM can be an intensity or binary image. The output image, IM2, is intensity or binary, respectively. The default connectivity is 8 for two dimensions, 26 for three dimensions, and CONNDEF(NDIMS(BW),‘maximal’) for higher dimensions.For intensity images, imclearborder tends to reduce the overall intensity level in addition to suppressing border structures.