关于膨胀和腐蚀的概念请参考:
https://blog.csdn.net/Ibelievesunshine/article/details/100522440
close all;clear all;clc;
I = imread('rice.png');
se = strel('square',2);
J = imdilate(I,se);
K = imerode(I,se);
L = J-K;
figure;
subplot(121);imshow(I);
subplot(122);imshow(L);title('图像边缘');