0

I’ve been working with text recognition in a dataset of images. I want to segment the characters of the image using components and finding contours of a thresholded image. However, many of the characters are merged with each other and with other components in the image.

Can you give me some idea for separating them? Thanks for the help!

Below are some examples, and part of my code:

Mat placa_contornos = processContourns(img_placa_adaptativeTreshold_mean);
vector<vector<Point>> contours_placa;
findContours(placa_contornos,
             contours_placa, 
             CV_RETR_EXTERNAL, externos)
             CV_CHAIN_APPROX_NONE); 
vector<vector<Point> >::iterator itc = contours_placa.begin();
while (itc != contours_placa.end()) {
    //Create bounding rect of object
    Rect mr = boundingRect(Mat(*itc));
    rectangle(imagem_placa_cor, mr, Scalar(0, 255, 0));
    ++itc;
}
imshow("placa con rectangles", imagem_placa_cor);

Results examples

original image, binarized image, result

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87

2 Answers2

0

I would try to erode the binary image more to see if that helps. You may also want to try fixing the skew and then removing the bottom line that connects the letters

Also, this might be relevant: Recognize the characters of license plate

Community
  • 1
  • 1
brad
  • 930
  • 9
  • 22
  • Thanks @brad, I have many images with lines in the top and the bottom that also i want eliminate, how can i eliminate the line? – Alexander33 Jan 26 '17 at 11:23
  • When I worked on a similar problem, I was able to check each row of the Mat to see if it had a lot of white pixels, indicating a horizontal line. However this approach may only work if you are able to correct the skew or the angle is constant. Otherwise perhaps another method of line detection may work – brad Jan 26 '17 at 15:35
0

You can try an opening operation on your thresholded image to get rid of the noise. You can adjust the kernel size based on your need.

// Get a rectangular kernel with size 7
Mat element = getStructuringElement(0, Size(7, 7), Point(1, 1));
// Apply the morphology operation
morphologyEx(placa_contornos, result, CV_MORPH_OPEN, element);

It gives the following intermediate output on your thresholded image, I guess it would improve your detection.

enter image description here

ilke444
  • 2,641
  • 1
  • 17
  • 31