4.2

4.2 | 5 ratings Rate this file 213 downloads (last 30 days) File Size: 10.38 KB File ID: #21366

find_components

by Tim Davis

 

07 Sep 2008 (Updated 09 Sep 2008)

Code covered by BSD License  

finds the connected components of an image

Download Now | Watch this File

File Information
Description

find_components finds the connected components of an image. Two pixels are in the same component if they are adjacent (north, south, east, or west, but not NW, SW, etc) and have the same value.

This was a bit of recreational weekend programming, in reply to Doug Hull's Puzzler of Aug. 18, 2008:

http://blogs.mathworks.com/pick/2008/08/18/puzzler-find-largest-connected-island/

It also serves as a nice example of DMPERM. To read more about dmperm, and to read its code, see CSparse or CXSparse on the File Exchange.

Acknowledgements
This submission has inspired the following:
ISLANDS
MATLAB release MATLAB 7.6 (R2008a)
Other requirements Your results will vary if you use MATLAB 7.4 or earlier; DMPERM was upgraded for MATLAB 7.5.
Zip File Content  
Other Files find_components/Contents.m,
find_components/find_components.m,
find_components/find_components.png,
find_components/find_components_example.m,
find_components/largest_component.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
30 Oct 2008 M P  
30 Oct 2008 John D'Errico

Professionally written. Excellent help. Internal comments that can teach everyone on the FEX something about how to write code.

30 Oct 2008 Kenneth Eaton

I hadn't ever happened upon DMPERM before. Thanks for pointing out something new, Tim.

18 Feb 2009 Ben Petschel

Nice code Tim. I hadn't come across DMPERM before either.

The variables K, East, South aren't really needed because K(E)=E, K(S)=S, East(E)=E+m, South(S)=S+1, and E & S can be defined without K.

07 Nov 2009 Thomas Clark

Thanks Tim!

This is very popular in the current ML contest (flooding a matrix with colour, Fall 2009).

Please login to add a comment or rating.
Updates
09 Sep 2008

Nice example, better plotting.

Tag Activity for this File
Tag Applied By Date/Time
morphology Tim Davis 22 Oct 2008 10:18:10
segmentation Tim Davis 22 Oct 2008 10:18:10
image Tim Davis 22 Oct 2008 10:18:10
connected components Tim Davis 22 Oct 2008 10:18:10
dmperm Tim Davis 22 Oct 2008 10:18:10
puzzler Tim Davis 22 Oct 2008 10:18:10
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com