标签:
膨胀 = 加长、变粗
%% 膨胀的应用A = imread(‘broken_text.tif‘);B = [0 1 0; 1 1 1; 0 1 0]; % 结构元素A2 = imdilate(A, B); % imdilate函数figure;subplot(1,2,1),imshow(A);subplot(1,2,2), imshow(A2);

%% 腐蚀的应用A = imread(‘wirebond_mask.tif‘);se = strel(‘disk‘, 10);A2 = imerode(A, se);figure;subplot(1,2,1), imshow(A);subplot(1,2,2), imshow(A2);


%% imopen imclose的应用A = imread(‘shapes.tif‘);se = strel(‘square‘, 20);A2 = imopen(A, se);figure;% subplot(1,2,1), imshow(A);% subplot(1,2,2), imshow(A2);A3 = imclose(A, se);imshow(A3);

%% 开闭结合f = imread(‘noisy_fingerprint.tif‘);se = strel(‘square‘, 3);fo = imopen(f, se); % 先做开操作foc = imclose(fo, se); % 后做闭操作figure;subplot(1,3,1), imshow(f);subplot(1,3,2), imshow(fo);subplot(1,3,3), imshow(foc);

%% 由重构做开运算% imreconstruct(marker, mask)% marker标记,变换的开始; mask约束变换过程,marker是mask的子集。f = imread(‘book_text.tif‘);fe = imerode(f, ones(51, 1));fo = imopen(f, ones(51, 1));fr = imreconstruct(fe, f);figure;subplot(2,2,1), imshow(f), title(‘原图‘);subplot(2,2,2), imshow(fe), title(‘腐蚀后图像‘);subplot(2,2,3), imshow(fo), title(‘开运算后图像‘);subplot(2,2,4), imshow(fr), title(‘重构后图像‘);

% 填充孔洞%f = imread(‘gt.tif‘);fh = imfill(f, ‘holes‘);figure;subplot(1,2,1), imshow(f), title(‘原图‘);subplot(1,2,2), imshow(fh), title(‘填充后图像‘);

% 清除边界对象fc = imclearborder(f); % 默认四连接figure;subplot(1,2,1), imshow(f), title(‘原图‘);subplot(1,2,2), imshow(fc), title(‘清除边界后图像‘);

标签:
原文地址:http://www.cnblogs.com/cnblogsnearby/p/4261790.html