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
76
votes
4 answers

How to use OpenCV's connectedComponentsWithStats in Python?

I am looking for an example of how to use OpenCV's connectedComponentsWithStats() function in Python. Note this is only available with OpenCV 3 or newer. The official documentation only shows the API for C++, even though the function exists when…
Zack Knopp
  • 2,765
  • 2
  • 13
  • 14
65
votes
15 answers

Merge lists that share common elements

My input is a list of lists. Some of them share common elements, eg. L = [['a','b','c'],['b','d','e'],['k'],['o','p'],['e','f'],['p','a'],['d','g']] I need to merge all lists, that share a common element, and repeat this procedure as long as there…
WlJs
  • 977
  • 1
  • 10
  • 12
27
votes
2 answers

connected component labeling in python

How to implement connected component labeling in python with open cv? This is an image example: I need connected component labeling to separate objects on a black and white image.
22
votes
3 answers

Detecting object regions in image opencv

We're currently trying to detect the object regions in medical instruments images using the methods available in OpenCV, C++ version. An example image is shown below: Here are the steps we're following: Converting the image to gray…
Maystro
  • 2,907
  • 8
  • 36
  • 71
17
votes
4 answers

How to aggregate matching pairs into "connected components" in Python

Real-world problem: I have data on directors across many firms, but sometimes "John Smith, director of XYZ" and "John Smith, director of ABC" are the same person, sometimes they're not. Also "John J. Smith, director of XYZ" and "John Smith, director…
Ian Gow
  • 3,098
  • 1
  • 25
  • 31
16
votes
4 answers

How to find connected components?

I'm writing a function get_connected_components for a class Graph: def get_connected_components(self): path=[] for i in self.graph.keys(): q=self.graph[i] while q: print(q) v=q.pop(0) if…
fege
  • 547
  • 3
  • 7
  • 19
12
votes
1 answer

Obtaining connected components of neighboring values

I have a matrix with values 0 or 1 and I would like to obtain a list of groups of adjacent 1's. Vertical and horisontal neighbors of each 1 are considered when defining the connected groups. For example, the matrix mat = rbind(c(1,0,0,0,0), …
Instanton
  • 399
  • 3
  • 13
10
votes
1 answer

Connected components on Pandas DataFrame with Networkx

Action To cluster points based on distance and label using connected components. Problem The back and forth switching between NetworkX nodes storage of attributes and Pandas DataFrame Seems too complex Index/key errors when looking up…
Tom Hemmes
  • 2,000
  • 2
  • 17
  • 23
10
votes
1 answer

get connected components using igraph in R

I would like to find all the connected components of a graph where the components have more than one element. using the clusters gives the membership to different clusters and using cliques does not give connected components. This is a follow up…
Dinesh
  • 2,194
  • 3
  • 30
  • 52
10
votes
1 answer

How to find all connected components in a binary image in Matlab?

I have been trying to find all connected components using 8 neighbors in a binary image, without using the function "bwlabel". For example, my input matrix is: a = 1 1 0 0 0 0 0 1 1 0 0 1 1 …
9
votes
1 answer

OpenCV Python cv2.connectedComponentsWithStats

Is it by design that you must pass cv2.connectedComponentsWithStats a white-on-black image as opposed to a black-on-white image? I get different results doing one versus the other. Example Code: import os import cv2 root = r'pth/to/img' fl =…
adam.hendry
  • 4,458
  • 5
  • 24
  • 51
9
votes
2 answers

Spark: What is the time complexity of the connected components algorithm used in GraphX?

GraphX comes with an algorithm for finding connected components of a graph. I did not find a statement about the complexity of their implementation. Generally, finding connected components can be done in linear time, for instance by a breadth-first…
7
votes
2 answers

Spark - GraphX - scaling connected components

I am trying to use connected components but having issue with scaling. My Here is what I have - // get vertices val vertices = stage_2.flatMap(x => GraphUtil.getVertices(x)).cache // get edges val edges = stage_2.map(x =>…
Shirish Kumar
  • 1,532
  • 17
  • 23
7
votes
3 answers

Calculating just a specific property in regionprops python

I am using the measure.regionprops method available in scikit-image to measure the properties of the connected components. It computes a bunch of properties (Python-regionprops). However, I just need the area of each connected component. Is there a…
optimist
  • 1,018
  • 13
  • 26
6
votes
2 answers

Python iterate through connected components in grayscale image

I have a gray scale image with values between 0 (black) and white (255). I have a target matrix of the same size as the gray scale image. I need to start at a random pixel in the gray scale image and traverse through the image one pixel at a time…
RaviTej310
  • 1,635
  • 6
  • 25
  • 51
1
2 3
21 22