Code covered by the BSD License  

Highlights from
getborder

Be the first to rate this file! 9 Downloads (last 30 days) File Size: 1.55 KB File ID: #12303
image thumbnail

getborder

by Wolfgang Schwanghart

 

18 Sep 2006 (Updated 04 Jan 2008)

returns a logical border inside or outside a mask

| Watch this File

File Information
Description

Ib = getborder(I,method)

getborder returns the outline around logical values in I (mask) using a 8-connected neighborhood.
I must be a logical n*m matrix. method 'inside' returns the inner border around "islands" of logical values. 'outside' returns the border outside the islands.
 
  Example:
 
  I = peaks(8)<0;
  
  Ib = getborder(I,'inside')
  
  Ib =
  
       0 0 1 1 1 1 1 1
       0 0 1 1 0 1 1 0
       1 0 0 1 1 1 0 0
       1 1 1 0 0 0 0 0
       1 1 1 0 0 0 0 0
       1 1 0 0 0 0 0 0
       0 0 0 0 0 0 0 0
       0 0 0 0 0 0 0 0
       
  Ib = getborder(I,'outside')
  
  Ib =
  
       0 1 0 0 0 0 0 0
       1 1 0 0 0 0 0 1
       0 1 1 0 0 0 1 1
       0 0 0 1 1 1 1 0
       0 0 0 1 0 0 0 0
       0 0 1 1 0 0 0 0
       1 1 1 0 0 0 0 0
       0 0 0 0 0 0 0 0

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
27 Sep 2006

As getborder(A,'inner') did not return 1 when a cell is surrounded by zeros only, I changed this. Sorry...

03 Jan 2008

speed increased by employing conv2, better handle input

04 Jan 2008

removed padding since it was not neccessary

Tag Activity for this File
Tag Applied By Date/Time
matrices Wolfgang Schwanghart 22 Oct 2008 08:39:45
border logical mask Wolfgang Schwanghart 22 Oct 2008 08:39:45
image processing Wolfgang Schwanghart 05 Jan 2010 03:13:00
matrix manipulation Wolfgang Schwanghart 05 Jan 2010 03:13:16
perimeter Wolfgang Schwanghart 05 Jan 2010 03:13:35
edge Wolfgang Schwanghart 05 Jan 2010 03:13:43

Contact us at files@mathworks.com