I have a processed captcha image(Enlarged) look like :
As you can see, the font-size of the \"TEXT\
You could use your own dilate and erode functions, wich will remove the smallest lines. A nice implementation can be found here.
I personally use dilate and erode as stated above but combine that with some basic statistics for width and height, try to find outliers and eliminate those lines as needed. After that, a filter which takes the minimum value of a kernel and turns the central pixel that color in a temporary image (iterating down the old image) before using the temporary image as the original should work. In pillow/PIL the minimum based task is accomplished with img.filter(ImageFilter.MINFILTER).
IF that is not enough, it should produce an identifiable set for which OpenCV's contours and minimum bounding rotated box can be used to rotate a letter for comparison (I reccomend Tesseract or a commercial OCR at this point since they have a ton of fonts and extra features like clustering and cleanup).
To quickly get rid of most of the lines, you can turn all black pixels with two or less adjacent black pixels white. That should fix the stray lines. Then, when you have a lot of "blocks" you can remove the smaller ones.
This is assuming the sample image has been enlarged, and the lines are only one pixel wide.