-1

I am very new to image processing and try to build a OCR for specific font using opencv and Python.

I am able to reduce the image below:Source Image

to this:

Mid level result

I have already written a small neural network to deduce character images into its respective English characters. Can someone help me to crop the cropped B/W image further into small images with just the characters?

The one way I could think of is by moving pixel by pixel and stop when a black pixel occurs. Is there any other way?

bazinga
  • 2,120
  • 4
  • 21
  • 35
  • since you have quite well defined blobs(letters) I suggest you [connectedComponents](http://docs.opencv.org/3.1.0/d3/dc0/group__imgproc__shape.html#gac2718a64ade63475425558aa669a943a) this will label each letter with a different number (for example H will have value 1 and I value 2 and so on, not necessary in this order). Then it is easy to create a mask for each of them and have an image for each letter – api55 Oct 06 '17 at 08:50
  • see related: [Interpretation of Horizontal and Vertical Summations of an Image](https://stackoverflow.com/a/39178204/2521214) and [Detecting space(bar) between words in a slanted font](https://stackoverflow.com/a/31086741/2521214) – Spektre Oct 06 '17 at 11:08
  • @api55 how can I apply connected components on a 3D vector? Because the shape of image is (x,y,z). – bazinga Oct 07 '17 at 14:26
  • now I just realize that you are working with python and not c++, the function is available in c++ (at least in 3.0). you can't to a 3D vector unless you can create an cv::Mat out of it (i.e. you have height and width) – api55 Oct 08 '17 at 09:29

1 Answers1

0

I think you should try cv::blobDetector

https://www.learnopencv.com/blob-detection-using-opencv-python-c/

Or just cv::findcountours with CV_EXTERNAL flag:

http://docs.opencv.org/3.1.0/df/d0d/tutorial_find_contours.html

ZdaR
  • 22,343
  • 7
  • 66
  • 87
Kamil Szelag
  • 708
  • 3
  • 12