0

I am developing an OpenCV application under Python. Several of the processing steps involve blob analysis (connected components labeling) after binarization. All is fine, except sometimes, when image noise is present, the number of blobs explodes and so does the processing time (say 1 second instead of 10 ms).

For the moment I am using the function connectedComponentsWithStats. I actually need the areas and centroids of the blobs.

Do you know of an alternative function which remains fast when there are many blobs, or which does a pre-filtering on size, or a way to apply a size filer on the binary image ?

  • did you try some morphological operation to remove small regions before doing the blob analysis? – Harry Dec 10 '18 at 13:43
  • @Harry: I'll do this as a last resort, because that will also change the blobs I need to see. –  Dec 10 '18 at 14:05
  • I've once written code to do exactly this (delete small blobs, but don't touch larger ones). The problem is: it's written in Python and therefore is terribly slow. You would have to translate it to C++, or even better to CUDA or OpenCL (algorithm can be perfectly parallelized). If this is OK for you I can share the code. – Harry Dec 13 '18 at 11:17
  • @Harry: that's kind of you. I already have fast C++ code, but this is not an option here. OpenCV/Python is mandated. –  Dec 13 '18 at 11:27

0 Answers0