matlab中图像处理的基本函数(1)
2019-04-15 13:48发布
生成海报
2017-8-19
读取彩 {MOD}图像(三维)
I1= imread('E: raining1s.jpg');
I1是一个m*n*t的矩阵
彩 {MOD}图像灰度化
I2=rgb2gray(I1);
灰度图像二值化
thresh = graythresh(I2); %自动确定二值化阈值
I3 = im2bw(I2,thresh);
其中thresh是可变的二值化阈值,这里的值为0.5255
灰度图像进行中值滤波处理(降噪)
I4=medfilt2(I2,[3,3]); %中值滤波
灰度图像进行边缘检测(roberts算子)
grayPic=mat2gray(I2);
[m,n]=size(grayPic);
newGrayPic=grayPic;
robertsNum=0;
robertThreshold=0.2;
for j=1:m-1
for k=1:n-1
robertsNum = abs(grayPic(j,k)-grayPic(j+1,k+1)) + abs(grayPic(j+1,k)-grayPic(j,k+1));
if(robertsNum > robertThreshold)
newGrayPic(j,k)=255;
else
newGrayPic(j,k)=0;
end
end
end
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮