0

Since OpenCV 3.0 has very useful function called connectedComponentsWithStats, I'm interested if there is a way to speed this function up?

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...

The image that we calculate anomalies from is 8-bit binary image calculated from grayscale image using OpenCV threshold function. I show this binary anomaly image here below:

enter image description here 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:

connectedComponentsWithStats(anomalyImg,
        OutputImg,
        stats,
        centroids,
        8,
        CV_32S
    );

The calculation takes me about 55 mili seconds and I want to optimize it to be at least 10 times faster.

Thank you already for all your advices guys!

Community
  • 1
  • 1
jok23
  • 286
  • 1
  • 5
  • 19
  • 1
    It's already as fast as it can be. You can try the new [CCC_GRANA](http://docs.opencv.org/master/d3/dc0/group__imgproc__shape.html#ga5ed7784614678adccb699c70fb841075) method which is the faster implementation and probably can get you a small boost. – Miki Oct 22 '16 at 08:05
  • 1
    And remember to compile in release mode! – Miki Oct 22 '16 at 08:08
  • 1
    CCL_GRANA methon I cannot use :S It says : ''Too many arguments in function call'. What am I doing wrong? Do I need to update OpenCV or why function doesn't accept parameter ccltype .My code is: connectedComponentsWithStats(anomalyImg, labeledImg, stats, centroids, 8, CV_32S, CCL_GRANA ); – jok23 Oct 22 '16 at 16:57
  • 2
    You need to compile the last github code – Miki Oct 22 '16 at 21:18

0 Answers0