Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
removing isolated element from a matrix

Subject: removing isolated element from a matrix

From: SM

Date: 14 Dec, 2011 15:29:12

Message: 1 of 3

Is there any simple way to remove the isolated values from a matrix?
The isolated element is the one for instant surrounded by 1 zero in the same row and 2 zeros in the same column and one zero in diagonal...

Assuming:
in=[ 1 1 1 1;...
      1 0 1 0;...
      1 1 1 1;...
      0 0 0 0;...
      0 0 0 0;...
      0 5 0 0;...
      0 0 0 1;...
      1 0 0 0;...
      0 5 0 0;...
      0 0 0 1];

then the out put shall not include the 5 in the 6th row:
out=[ 1 1 1 1;...
      1 0 1 0;...
      1 1 1 1;...
      0 0 0 0;...
      0 0 0 0;...
      0 0 0 0;...
      0 0 0 1;...
      1 0 0 0;...
      0 5 0 0;...
      0 0 0 1];

Subject: removing isolated element from a matrix

From: dpb

Date: 14 Dec, 2011 18:59:22

Message: 2 of 3

On 12/14/2011 9:29 AM, SM wrote:
> Is there any simple way to remove the isolated values from a matrix?
> The isolated element is the one for instant surrounded by 1 zero in the
> same row and 2 zeros in the same column and one zero in diagonal...
...

Don't have any great ideas; one possible that comes to mind would be to
convert to a logic array and apply a convolution filter/matching to the
columns in question. But, don't see any way other than run that across
the area.

Alternatively, might consider turning into an image an looking at it as
a image processing problem of boundaries/edge detection.

Hmmm...that strikes as making the first logical array and it's edge
detection there as well (connected edges, precisely).

--

Subject: removing isolated element from a matrix

From: Doron avramov

Date: 21 Dec, 2012 08:18:11

Message: 3 of 3

dpb <none@non.net> wrote in message <jcarm7$nm7$1@speranza.aioe.org>...
> On 12/14/2011 9:29 AM, SM wrote:
> > Is there any simple way to remove the isolated values from a matrix?
> > The isolated element is the one for instant surrounded by 1 zero in the
> > same row and 2 zeros in the same column and one zero in diagonal...
> ...
>
> Don't have any great ideas; one possible that comes to mind would be to
> convert to a logic array and apply a convolution filter/matching to the
> columns in question. But, don't see any way other than run that across
> the area.
>
> Alternatively, might consider turning into an image an looking at it as
> a image processing problem of boundaries/edge detection.
>
> Hmmm...that strikes as making the first logical array and it's edge
> detection there as well (connected edges, precisely).
>
> --Hi
i would suggest to check
BW2 = bwmorph(BW,operation)
with operation='clean'
it is specificllay aimed toward "Removin isolated pixels (individual 1s that are surrounded by 0s), such as the center pixel in this pattern".

http://www.mathworks.com/help/images/ref/bwmorph.html
Doron

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us