0

I need to remove all blobs at image, but cannot do it. I tried many thresholding operations, but nothing helps. I'm using OpenCV and Qt (C++). Example:

cv::adaptiveThreshold(input, output, 125,
      ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 13, 25);

Input/Output:

Input Image

Output Image

1
  • 1
    It is quite possible that your time developing any sort of a solution is more expensive than the cost of third-party APIs that solve that problem and charge per-captcha. Have you considered that option? Also, why did you assume that thresholding will somehow remove blobs? That's not what it does. Commented Aug 29, 2017 at 17:42

1 Answer 1

4

It seems you're like hacking something :)

I suggest you try with some Blob Detection algorithm... give a look to this link. Then you can filter blobs by area for example.

Here a short snippet:

using namespace cv;
// Read image
Mat im = imread( "blob.jpg", IMREAD_GRAYSCALE );

// Set up the detector with default parameters.
SimpleBlobDetector detector;

// Detect blobs.
std::vector<KeyPoint> keypoints;
detector.detect( im, keypoints);

// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints( im, keypoints, im_with_keypoints, Scalar(0,0,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );

// Show blobs
imshow("keypoints", im_with_keypoints );
waitKey(0);

This is the result: enter image description here

All the blobs are highlighted with a circle

Also morphological operations can improve the image. In particular, an opening and closing operation can improve the image and remove noise:

This after opening:

Opening

This after a closing operation:

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

This kinda reads more like a comment than an answer, but it does link to the solution (although dropping links in place of code in answers is frowned upon here).
@RTbecard I've modified the reply so it doesn't depend on the links anymore. Thank you for the suggestion.
Great! I've come across more than few questions where the only relevant answer for me buried critical info in dead links. Thanks for taking the time to update an old answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.