4.0

4.0 | 4 ratings Rate this file 237 downloads (last 30 days) File Size: 9.25 KB File ID: #21366

find_components

by Tim Davis

 

07 Sep 2008 (Updated 09 Sep 2008)

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 (4)
30 Oct 2008 Marco  
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.
31 Oct 2008 vgood  
Please login to add a comment or rating.
Updates
09 Sep 2008 Nice example, better plotting.

Public Submission Policy

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 Disclaimer prior to use.

Contact us at files@mathworks.com