Questions tagged [connected-components]

Connected-component labeling (alternatively connected-component analysis, blob extraction, region labeling, blob discovery, or region extra

Connected-component labeling (alternatively connected-component analysis, blob extraction, region labeling, blob discovery, or region extra

327 questions
6
votes
3 answers

How to count all the connected nodes (rows) in a graph on Postgres?

My table has account_id and device_id. One account_id could have multiple device_ids and vice versa. I am trying to count the depth of each connected many-to-many relationship. Ex: account_id | device_id 1 | 10 1 | 11 1 | 12 2 | 10 3 | 11 3 | 13 3 |…
cvax
  • 416
  • 1
  • 5
  • 12
5
votes
3 answers

python find connected components in a 3D graph / tuple with three elements?

I have a binary 3D numpy array, for which I would like to find connected components, i.d. neighbor elements with value 1. data = np.random.binomial(1, 0.4, 1000) data = data.reshape((10,10,10)) Alternatively I can get the coordinates for each…
hirschme
  • 774
  • 2
  • 11
  • 40
5
votes
1 answer

Implementation and speed differences of cv::connectedComponents vs cv::findContours

I'm trying to optimise some of our computer vision algorithms and decided to benchmark cv::connectedComponents against cv::findContours (and cv::drawContours) to achieve similar results. Essentially, all we need to do is find blobs in a binary…
n00dle
  • 5,949
  • 2
  • 35
  • 48
5
votes
3 answers

Contour of a run-length-coded digital shape

A digital shape is a set of connected pixels in a binary image (a blob). It can be compactly represented by run-length coding, i.e. grouping the pixels in horizontal line segments and storing the starting endpoint coordinates and the lengths.…
user1196549
5
votes
1 answer

R / SQL /Python : Extracting connected components from node-edge pairs

I struggle to come up with a title that describes what I'm trying to solve, so please comment if you have a better title! The solution can be in R, Python, or SQL (Aster TeraData SQL to be exact, though a solution any SQL language is very helpful…
so13eit
  • 942
  • 3
  • 11
  • 22
4
votes
3 answers

Minimum amount of edges to remove to create k connected components in an undirected graph?

How do I approach the problem: Minimum amount of edges to remove to create k connected components? The graph might already be a forest, though not necessarily one with k connected components, and may have cycles. It is unweighted and undirected.
4
votes
1 answer

Generate graph from a list of connected components

Setup Let's assume the following undirected graph: import networkx as nx G = nx.from_edgelist([(0, 3), (0, 1), (2, 5), (0, 3)]) G.add_nodes_from(range(7)) or even adding the (1, 3) edge (it doesn't matter here): The connected components…
mozway
  • 194,879
  • 13
  • 39
  • 75
4
votes
1 answer

How to use python OpenCV to find largest connected component in a single channel image that matches a specific value?

So I have a single channel image that is mostly 0s (background), and some values for foreground pixels like 20, 21, 22. The nonzero foreground pixels are mostly clustered together with other foreground pixels with the same value. However, there is…
4
votes
3 answers

how to model complex shapes using representative points?

I want to reduce the amount of white pixels in this image to just some candidate or representative points in the output image (goal is to model different types of shapes) if you just connect the gray points in the output image together you have…
PsP
  • 696
  • 3
  • 10
  • 34
4
votes
2 answers

Python connected components with pixel list

In matlab you can use cc = bwconncomp(bimg); pixels = cc.PixelIdxList{i} To get pixel list of each connected components. What's the python equivalent? I tried from skimage import measure label = measure.label(bimg) To get the labels, however,…
venusisle
  • 113
  • 2
  • 10
4
votes
1 answer

Spark: GraphX fails to find connected components in graphs with few edges and long paths

I'm new to Spark and GraphX and did some experiments with its algorithm to find connected components. I noticed that the structure of the graph seems to have a strong impact on the performance. It was able to compute graphs with millions of vertices…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
4
votes
2 answers

Algorithm for finding every weakly connected component of a directed graph

I am searching for an algorithm for finding every weakly connected component in a directed graph. I know for an undirected graph you can do this via a dfs but this obviously doenst work for an directed graph. I am saving my graph as an adjacents…
Exagon
  • 4,798
  • 6
  • 25
  • 53
4
votes
1 answer

OpenCV 3.0 Connected components, can't get it to work properly

I have the following code, it's just a simple test program to learn how to use the connected components functionality in openCV 3.0 int main(int argc, char** argv) { char* line = argv[1]; Mat image; image = imread(line,CV_LOAD_IMAGE_GRAYSCALE); …
jsa
  • 397
  • 2
  • 14
4
votes
2 answers

Adjacency matrix neighbors

I have a matrix with 0s and 1s. I can start from any cell. I want to know what is the minimum number of steps(up,down,left,right) required to cover all possible 1s. I can start from 0 or 1. Example: 0 1 0 1 1 1 0 1 0 Start from (2,2) within 1 step…
4
votes
1 answer

Numpy/Scipy Connected Components

I am writing a program in python to find "islands" of 1s, 0s or -1s in a L*L matrix. I need It to find these "regions" of connected components, label each one of them, and be capable of returning, for a given element of the matrix m[x][y] , the size…
albertociarr
  • 41
  • 1
  • 2
1
2
3
21 22