View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Get Largest Connected Components

5.0 | 4 ratings Rate this file 15 Downloads (last 30 days) File Size: 1.79 KB File ID: #39094 Version: 1.1
image thumbnail

Get Largest Connected Components



19 Nov 2012 (Updated )

Get n largest connected-components in n-d array, with arbitrary connectivity support

| Watch this File

File Information

The function returns N-D logical array (same size as the input array) with the n largest connected-components indices set.

Xin - input N-D array. Required.

conn - connectivity definition, can be either a scalar or connectivity array, with same number of dimensions as the input array. If empty or omitted , 'conn' will be set to scalar 3^ndims(Xin)-1.

n - Number of returned largest connected-components. If omitted, 'n' will be set to 1. If 'n' is greater than N, the actual number of connected-components in the array, N will be used instead.

Xout - Output N-D array (same size as Xin), with only the n largest connected-components indices set.

rp - vector of length n of structures containing information about the size of the connected-components and their indices, arranged in descending order of size.

Example (2D):
I = rand(100,100) > 0.75;
[J rp] = getLargestCc(I,[],3);

I is a random 2D "image". J is a copy of I with only the 3 largest connected-components set.
Despite the fact that the example is for a very simple 2D image, the code applies to N-D arrays as well.

Comments and questions to:

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
10 Mar 2014 Chulmin Chulmin

10 Aug 2013 lemonmi

06 Aug 2013 lemonmi

03 Jul 2013 Vikram

Vikram (view profile)

19 Nov 2012 1.1

Just fixed the description part.

Contact us