close all;clear all;clc;
% 開運算和閉運算
I = imread('testpic.jpg');
I = im2bw(I);
I = ~I;
se = strel('line',5,90);
J = imopen(I,se);
K = imclose(I,se);
figure;
subplot(131);imshow(I);title('原圖像');
subplot(132);imshow(J);title('開運算');
subplot(133);imshow(K);title('閉運算');