The images are attached here. I first converted the sample image to grayscale and then binarized it.

Finally i applied median filter to remove the dots from the image. However i am unable to remove the lines which are acting as noise in the image. Kindly help me out.

Original Image:

Original Image

Processed Image:

Processed Image

  • $\begingroup$ @ gabonator @Andrea :I could not implement dilation and erosion as I know the concept of it but I couldn't find the java code nor the algorithm which I can follow regarding this topic. I seriously need help and if someone can give me the complete code or the algorithm with which i can extract all the characters from the captcha image that would be wonderful. Also I could not comment as I do not have enough reputation. I tried implementing whatever you mentioned but it did not work for this case. Please help me out. $\endgroup$
    – hdhj
    Commented May 24, 2018 at 5:21
  • $\begingroup$ @hdhj This seems to be your question, but created using a different account. Please merge your accounts first. Then, please update this question with any new information you have that might help us to give you the sort of answer you are asking for. Please do not post a duplicate question again..... $\endgroup$
    – Peter K.
    Commented May 24, 2018 at 12:43

2 Answers 2


I worked on this problem some time ago, my solution was to compress the image with wavelet transform with an opportune coefficient that depends on captcha type that I choose with some expermients. Then I saturate the compressed image from mean value to 0 and 1 in order to create a mask. Next I multiply mask to the original image and I get the image without lines or noise. I post a picture example where I use also a derivative filter on the result but in reality you don't need it.

Your lines are a bit different but I think that you can start from this approach because your lines are more thin than text so wavelet compression can works but you have to improve it for your problem.

Finally your lines have different color and you can use also this information.

enter image description here


Apply lower threshold when binarizing the image - you can distinguish three different types of pixels in the image - white background, gray noise and lines, and black characters. By choosing the thresholding level between background and gray you should easily remove lines including the dot noise. Then you will need to apply some morphological operations (dilation/erosion) to fill the holes, since the lines are drawn on top of the characters


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.