Skip to content
Back to formatted view

Raw Message

Message-ID: <CAMXOh=214J3yx5_VqAZy39O2eXDEAJQwhnnWkwNZEGP8f7hHiQ@mail.gmail.com>
Date: 2016-04-05T09:29:14Z
From: Andres Diaz Loaiza
Subject: Equivalent imclearborder matlab function

Hi everybody,

Someone known an equivalent function for imclearborder? Basically
imclearborder detects when a path is connected to the border of a matrix
(raster, grid etc..) and remove the binary data

In the example of mathlab (BW is the original matrix):

BW = [0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      1     0     0     1     1     1     0     0     0
      0     1     0     1     1     1     0     0     0
      0     0     0     1     1     1     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0];


Clear pixels on the border of the image using 4-connectivity.

BWc1 = imclearborder(BW,4)


BWc1 =

     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     1     1     1     0     0     0
     0     1     0     1     1     1     0     0     0
     0     0     0     1     1     1     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0


 Note that imclearborder does not clear the pixel at (5,2) because, with
4-connectivity, it is not considered connected to the border pixel at (4,1).

with 8-conectivity

BWc2 = imclearborder(BW,8)


BWc2 =

     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     1     1     1     0     0     0
     0     0     0     1     1     1     0     0     0
     0     0     0     1     1     1     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0     0


Thank you in advance.



Andr?s D.

	[[alternative HTML version deleted]]