[学习笔记]形态学图像处理-击中或击不中变换

击中或击不中变换是形态检测的一个基本工具。他是一个整体,方法中包括击中部分跟击不中部分。

输出图像由所有在B1中匹配的像素(击中)和未在B2中匹配的像素(击不中)组成。

例子:

f = imread('FigP0918(left).tif')
imshow(f)
B1 = strel([0 0 0; 0 1 1; 0 1 0])
B2 = strel([1 1 1; 1 0 0; 1 0 0])
g = bwhitmiss(f,B1,B2)
figure()
imshow(g)

处理前:

处理结果:

http://blogs.mathworks.com/steve/2008/05/13/lookup-tables-makelut-applylut/

如果击中或击不中不止一个结构元时,使用查表法:

例子:

function g = endpoints(f)
    persistent lut
    if isempty(lut)
        lut = makelut(@endpoint_fcn,3);
    end
    g = applylut(f,lut);

function is_end_point = endpoint_fcn(nhood)
    is_end_point= nhood(2,2)&(sum(nhood(:))==2)
f = imread('Fig0914(a)(bone-skel).tif')
imshow(f)
g = endpoints(f)
figure
imshow(g)

源图像:

处理结果:

原文地址:https://www.cnblogs.com/irish/p/3333489.html