Thread Subject: finding connected spaces in a matrix

Subject: finding connected spaces in a matrix

From: Florian

Date: 25 Nov, 2009 12:54:03

Message: 1 of 3

Hey everyone,

I have the following problem:
Let's say you have a matrix

A=[0 0 1 1 0 0;0 0 1 1 1 1;0 0 0 1 0 1;0 1 1 1 0 1;0 1 1 0 0 0]

The question now is:
How many connected areas (http://en.wikipedia.org/wiki/Connected_space) of 1s are there in the matrix and how large are these?

In the above example the answer is:
connected areas: 1
area: 14

Is there a smart way to do this in Matlab, or can somebody point me towards an efficient algorithm?

For my real problem I need to find these connected spaces in a multi dimensional matrix. A hint on how to start would be highly appreciated.

Thanks for your reply,
Florian

Subject: finding connected spaces in a matrix

From: Bruno Luong

Date: 25 Nov, 2009 13:10:25

Message: 2 of 3

Labeling algorithm is for this kind of problem:

http://www.mathworks.com/access/helpdesk/help/toolbox/images/bwlabeln.html

Bruno

Subject: finding connected spaces in a matrix

From: Florian

Date: 25 Nov, 2009 13:27:06

Message: 3 of 3

Thanks Bruno...this is exactly what I've been searching for! :)

Have a great day,
Florian

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
connected space Florian 25 Nov, 2009 07:59:21
rssFeed for this Thread

Contact us at files@mathworks.com