Rahul
Rahul

Reputation: 21

Connect pixels in matlab

Please suggest how to connect the dotted pixels in an image like below:

Test imageOriginal Image

I want to apply OCR on this image. I have tried some morphological operations such as thickening and bridging but not obtaining the correct output as expected (NH5343320). The original image is also uploaded. On applying horizontal edge detection on the original image, I got the dotted image as above. Is there any another methods available for applying OCR in these kind of images.

Upvotes: 0

Views: 255

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207405

I would crop out and fill in a template for each of the available letters. Presumably, that would be the letters [A-Z] and the digits [0-9] like this.

0.png

enter image description here

3.png

enter image description here

Now I would do a sub-image search for each of them in your original image. I am doing this at the command-line with ImageMagick but you could use Matlab, OpenCV, or CImg or the Python, Perl, PHP, C, C++ bindings of ImageMagick.

So, I look for the 3 first:

compare -metric rmse -dissimilarity-threshold 1 -subimage-search plate.png 3.png result.png
25607.9 (0.390752) @ 498,46

So, the 3 is found at coordinates 498,46. There will be 2 output files, output-0.png which looks like this:

enter image description here

and output-1.png in which you can see the brightest areas showing where the match is best:

enter image description here

Likewise with the 0:

compare -metric rmse -dissimilarity-threshold 1 -subimage-search plate.png 0.png result.png
31452.6 (0.479936) @ 664,44

enter image description here

enter image description here

Upvotes: 1

Related Questions