title: How to speed up connectedComponentsWithStats in C++ (OpenCV)
body: <p>Since OpenCV 3.0 has very useful function called <em>connectedComponentsWithStats</em>, I'm interested if there is a way to speed this function up?</p>
  <p>I'm working on a project in whitch I have to calculate properties of anomalies. This properties are wery good calculated with connectedComponentsWithStats function, but I need more speed here...</p>
  <p>The image that we calculate anomalies from is 8-bit binary image calculated from grayscale image using OpenCV <em>threshold</em> function. I show this binary anomaly image here below:</p>
  <p><a href="https://i.stack.imgur.com/i2G4E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i2G4E.png" alt="enter image description here" /></a>
  We can se black area - this is our region of interest (ROI). On the ROI we can se white anomalies (dots, lines, scrathes..). For that anomalies I have to calculate centroids, areas and similar properties that function connectedComponentsWithStats does very ok, but it is not fast enought for my application. My code for calculation of properties is here:</p>
  <pre><code>connectedComponentsWithStats(anomalyImg,
          OutputImg,
          stats,
          centroids,
          8,
          CV_32S
      );
  </code></pre>
  <p>The calculation takes me about 55 mili seconds and I want to optimize it to be at least 10 times faster.</p>
  <p>Thank you already for all your advices guys!</p>