title: Image Segmentation based on Pixel Density
body: <p>I need some help developing some code that segments a binary image into components of a certain pixel density. I've been doing some research in OpenCV algorithms, but before developing my own algorithm to do this, I wanted to ask around to make sure it hasn't been made already.</p>
  
  <p>For instance, in this picture, I have code that imports it as a binary image. However, is there a way to segment objects in the objects from the lines? I would need to segment nodes (corners) and objects (the circle in this case). However, the object does not necessarily have to be a shape. </p>
  
  <p>The solution I thought was to use pixel density. Most of the picture will made up of lines, and the objects have a greater pixel density than that of the line. Is there a way to segment it out?</p>
  
  <p>Below is a working example of the task.</p>
  
  <p><strong>Original Picture:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/E9ub2.jpg" alt="Original Picture"></p>
  
  <p><strong>Resulting Images after Segmentation of Nodes</strong> (intersection of multiple lines) and Components (Electronic components like the Resistor or the Voltage Source in the picture)</p>
  
  <p><img src="https://i.stack.imgur.com/YUAfS.jpg" alt="Node 1"></p>
  
  <p><img src="https://i.stack.imgur.com/MKtPN.jpg" alt="Voltage Source"></p>
  
  <p><img src="https://i.stack.imgur.com/y0cSm.jpg" alt="Node 2"></p>
  
  <p><img src="https://i.stack.imgur.com/Ath0Y.jpg" alt="Resistor"></p>
  
  <p><img src="https://i.stack.imgur.com/x8BwR.jpg" alt="Node 3"></p>
  
  <p><img src="https://i.stack.imgur.com/NfJ18.jpg" alt="Node 4"></p>