这篇博客是接着上一篇来哒,https://blog.csdn.net/luolan9611/article/details/94285158
本篇博客及上篇博客搜集的资料、实验代码、实验报告、PPT均已上传至百度网盘:
链接:https://pan.baidu.com/s/1AmT4TtBAxj1FKf4KUFcsBw 提取码:kcfe
先上结果~
再上代码~
唔,要说明的是我使用的是matlabR2018a,如果用matlab2019的话,代码要有些变化,因为函数接口什么的会变...
%读取原始图像,并将之转换为灰度图
Irgb = imread('zx_in_xidian.jpg');
Igray=rgb2gray(Irgb);
%绘制原始图像和灰度图
figure
image(Irgb,'CDataMapping','scaled')
title('Input Image in Rgbscale');
figure
image(Igray,'CDataMapping','scaled')
colormap('gray')
title('Input Image in Grayscale');
%将灰度图转换为双精度表示
I=im2double(Igray);
%定义Gx和Gy,将之与I卷积
Gx=[-1 1];
Gy=Gx';
%Ix=mapminmax(conv2(I,Gx,'same'));
%Iy=mapminmax(conv2(I,Gy,'same'));
Ix=conv2(I,Gx,'same');
Iy=conv2(I,Gy,'same');
%绘制Ix和Iy
figure
image(Ix,'CDataMapping','scaled')
colormap('gray')
title('Ix')
figure
image(Iy,'CDataMapping','scaled')
colormap('gray')
title('Iy')
%定义图像边缘检测的模糊推理系统
edgeFIS=newfis('edgeDetection');
%定义模糊推理系统的输入
edgeFIS = addvar(edgeFIS,'input','Ix',[-1 1]);
edgeFIS = addvar(edgeFIS,'input','Iy',[-1 1]);
%sx和sy分别作为高斯隶属函数中相应的sigma标准差
sx=0.1;
sy=0.1;
edgeFIS = addmf(edgeFIS,'input',1,'zero','gaussmf',[sx 0]);
edgeFIS = addmf(edgeFIS,'input',2,'zero','gaussmf',[sy 0]);
%定义模糊推理系统的输出
edgeFIS