Decompress Binary Characters

I am working on license plate recognition. The problem is that I have to decrypt the characters in the binary image in order to increase the accuracy of pattern matching.

I did a lot of preprocessing to remove the unnecessary pixels of the image, and I could segment the characters. But, unfortunately, they are skewed.

From ... grayscale to binary conversion

enter image description here

Then .. preprocessing methods.

enter image description here

After segmentation ..

enter image description here

As you can see in the last image, the characters are skewed, and this will lead to inaccurate pattern matching to meet recognition goals.

Most researchers use the Hough transform to perform a skew operation, but is there an easier way to do this?

+5
source share
2 answers

There are ways to handle this. Some of the suitable parts to avoid unskew operations are like this:

But you want unskew to:

  • determine the angle of rotation / angle of inclination

    Get a bounding box, then draw vertical scan lines and remember the first hit point and the last regression line through all of them

    algo overview

  • rotate / bend back

    Thus, either use atan2 to obtain the angle, or directly construct a two-dimensional homogeneous 3x3 transformation matrix based on basis vectors (one is a line and the other is its perpendicular vector). For more information see:

  • Now the image with a rotating / immodest image will still be a distorted bud at a much lower speed

    so that you can apply # 1, # 2 on the horizontal axis, but this time you need unskew (don't use rotation). Typically, the skew coefficient of the residues is small, so this step is not required.

[notes]

You can improve accuracy by filtering out incorrect points or by carefully selecting the starting point of the scan lines so that they get to the right place for the characters (you obviously know the number of characters).

[edit1] small example

Here's a small sample output for your image (Negative, since my functions expect white paper and black font):

example

As you can see, rotation and skew are much less.

+4
source

You can find the angle of rotation of your distorted black and white data as well as an analysis of the main components of a set of points consisting of all the white pixels in your image.

Here is the code:

 % load image img = imread('skewed.png'); img = img(:, :, 1); img = double(img); % perform pca on cloud of white points [r, c] = find(img); coeff = pca([r,c]); angle = atan2(coeff(1,1), coeff(1,2)); % rotate back img = imrotate(img, angle / pi * 180); imwrite(img > 0, 'deskewed.png'); 

Input:

enter image description here

Output (angle of rotation ~ 10.3 degrees):

enter image description here

+1
source

All Articles