User Tools

Site Tools


ece4580:module_pcd:connectedcomponents

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ece4580:module_pcd:connectedcomponents [2017/02/10 19:46] pvelaece4580:module_pcd:connectedcomponents [2024/08/20 21:38] (current) – external edit 127.0.0.1
Line 6: Line 6:
  
 Here is the main algorithm for doing so: Here is the main algorithm for doing so:
-<code> + 
-  Compute the proximity matrix (see ''pdist''). +  Compute the proximity matrix (see ''pdist''). 
-  Apply a threshold to the proximity matrix to get the connectivity matrix $C$. +  Apply a threshold to the proximity matrix to get the connectivity matrix $C$. 
-  Find the first row with a non-zero as the index. +  Find the first row with a non-zero as the index. 
-  While there is an index to grab +  - numSets = 0 
-    Grab a random point from the point cloud. Let its index be $i$. +  - Set labels to be a 1 x $n_p$ matrix where $n_p$ is the number of points in the point cloud. 
-    Initialize the index set $S = {i}$. +  - While there is an index to grab 
-    Initialize the neighbor index set $N = {i}$. +    * numSets = numSets + 1 
-    While the neighbor set is not empty, do the following: +    * Grab a random point from the point cloud. Let its index be $i$. 
-      Zero out the rows for the current neighbor index set ($C(N,:) = 0$). +    Initialize the index set $S = {i}$. 
-      Given the neighbor set, find its connected components  +    Initialize the neighbor index set $N = {i}$. 
-        There are all of the indices that are non-zero in the column $C(N,:$))+    While the neighbor set is not empty, do the following: 
-      Add these indices to the index set $S$. +      Zero out the rows for the current neighbor index set ($C(N,:) = 0$). Makes them no longer available
-      Set the new neighbor set $N$ to the connected components. +      Given the neighbor set, find indices of its connected components. These are all of the indices that are non-zero in the column $C(N,:)$. 
-    End +      Add these indices to the index set $S$. 
-  End +      * SOverwrite the neighbor index set $N$ to the found connected components. 
-</code>+    * The index set $S$ forms a cluster. 
 +    * Set labels($S$) = numSets 
 + 
 +Each time a new set $S$ is computed, it defines a connected component cluster. The indices in the set $S$ are then used to label the points.  The variable labels indicates what label each point is in, in order of the points stored in the point cloud matrix.  In the code stub, there is code to generate a matrix of different color values by hue for each label.  Use that to generate a large matrix that is $n_p$ x 3 of colors, where the color chosen is based on the label assignment. This color matrix can be computed in one line of code if you know your Matlab.  Invoke the ''setColor'' function with the matrix to assign a color to each point.  The next time you plot the points, they will be colored according to their assignment. 
 +The labels variable should be returned. 
  
 ----------------------- -----------------------
ece4580/module_pcd/connectedcomponents.1486773975.txt.gz · Last modified: 2024/08/20 21:38 (external edit)