I have noisy images from which I extract the contours using OpencCV's findCountours, which performs binarization internally. This results in innumerable small outlines made of three or four pixels, which I would like to avoid.

I want to discard these, either before extracting the contours, or during that step. I could binarize the image myself and use a size filter (i.e. erase the blobs tiny in area), or I could use a variant of the contouring function that implicitly discards the very short outlines.

But I can't find OpenCV functions that look like this. Any hint ?

Note that I don't want to use any denoising function, as it will degrade the signal. I don't want to erode either, for the same reason.

Example of outlines to be discarded (don't mind the annotations):

enter image description here

I am not asking to get rid of all noisy blobs, but of the smallest ones.

  • $\begingroup$ Can a Hough transform do the job for you? Are lines you do want usually strait lines? $\endgroup$ – havakok Jul 17 '19 at 15:26
  • $\begingroup$ @havakok: sorry, I want to discard the tiny blobs, and nothing else. $\endgroup$ – Yves Daoust Jul 17 '19 at 15:51
  • $\begingroup$ Can't you just calculate their size and discard all blobs below a certain threshold? $\endgroup$ – T A Jul 18 '19 at 11:46
  • $\begingroup$ @TA: that would be a circular solution. I want to get rid of the small blobs to avoid detecting them. $\endgroup$ – Yves Daoust Jul 18 '19 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.