FUNCTION REFERENCE
strel
Flat morphological structuring element.
Flat morphological structuring element.
Syntax
SE = strel(nhood)Syntax
SE = strel('arbitrary', nhood)Syntax
SE = strel('square', w)Syntax
SE = strel('rectangle', [m n])Syntax
SE = strel('diamond', r)Syntax
SE = strel('disk', r)Syntax
SE = strel('disk', r, n)Syntax
SE = strel('line', len, deg)Syntax
SE = strel('octagon', r)Returns a strel object with the properties Neighborhood (logical matrix of the members) and Dimensionality (2). The origin of the element is element (floor((rows+1)/2), floor((cols+1)/2)) of the neighborhood. nhood is any logical or numeric 2-D matrix (nonzero = member). 'square' is a w-by-w block; 'rectangle' an m-by-n block; 'diamond' the points with |x| + |y| <= r; 'disk' with n = 0 the exact disk x^2 + y^2 <= r^2; 'octagon' (r a multiple of 3) the points with |x|, |y| <= r and |x| + |y| <= 4r/3; 'line' a digital line of length about len through the origin at deg degrees counterclockwise from the x axis (along its major axis every integer offset t with |t| <= round((len-1)/2 times |cos deg| or |sin deg|), the other coordinate rounded half away from zero, so the line is symmetric about its centre). 'disk' with n = 4, 6 or 8 (default 4) is approximated by periodic lines (Adams, 1993; Jones and Soille, 1996): lines in n lattice directions whose sum is a polygon of inradius a <= r, dilated by the exact disk of radius floor(r - a). Plain logical or double neighborhoods are accepted wherever a strel is.
Example
SE = strel('square', 3); SE.Neighborhood % true(3)Example
SE = strel('disk', 2, 0); SE.Neighborhood % [0 0 1 0 0; 0 1 1 1 0; 1 1 1 1 1; 0 1 1 1 0; 0 0 1 0 0]Example
SE = strel('line', 5, 45); SE.Neighborhood % fliplr(eye(3))Example
class(strel('diamond', 1)) % 'strel'Differences from MATLAB: flat 2-D elements only: 'ball', 'sphere', 'cube', 'cuboid', 'periodicline', 'pair' and non-flat elements are not supported yet, and no decomposition is stored or reported. The n > 0 disk shapes are built from the published method and may differ from MATLAB's at the edges; line elements at angles other than multiples of 45 degrees may differ by a pixel.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.