Code covered by the BSD License  

Highlights from
expandBW

expandBW

by

 

This function is used to expand the perimeter of a binary image by one pixel

expandBW(bw)
function [newBW] = expandBW(bw)
%EXPANDBW - expands the perimeter of a bw feature by one pixel
%
%   expandBW(bw) bw is a binary image or logical matrix
%   
%   Author: Matt Le (lexxx320@umn.edu)
%   Date: June 18, 2012
%  
%    
%   a = zeros(10);
%   a(3:5, 3:5) = 1;
%   outterPerim = expandBW(a);
%
%   To get the newly expanded perimeter and the original feature, you can do 
%   expandBW(a) | a
%

bw = logical(bw);

newBW = imdilate(bw, ones(3)) & ~bw;


end

Contact us