Compute Vertical Gradients for License Plate Localization

336 Views Asked by At

I am new with MATLAB and trying to implement the following step of License Plate Localization:

Vertical Gradient Computation

Here's my progress so far.

Code:

[rows,cols] = size(img);
image_gradient = zeros(rows,cols);

for i =1:1:rows
    for j =1:1:cols-1
        image_gradient(i,j) = abs( img(i,j+1) - img(i,j) );
    end
end

figure,imshow(image_gradient);title('Gradient');

Output:

Output of gradient computation

I will be indeed grateful if someone can guide me what I am doing wrong here.

1

There are 1 best solutions below

3
On BEST ANSWER

Well to start off you should understand that illumination is a pain in the backside. And you shall understand that as you keep learning new algorithms.

Looking at your first set of images you can see that the plate is a prominent part of the image. Number plates are designed to give this contrast between the characters and the background. Moreover the entire background is fairly smooth. When you look at the image on the bottom there are a lot of artifacts and sharp intensity transitions, This should explain why your gradient is noisy.

What you are essentilly trying to do is a filtering operation ( Or Convolution ) using a filter that looks like this [-1 1]. Look up matlab functions conv2 and filter.

To reduce the noise you should be performing an averaging operation along with the gradient. This will reduce the susceptibility to noise. So your final filter would look something like this [-1 1;-1 1;-1 1]. Make sure your filter values are normalized if your are trying other complex filters.

Detecting number plates is not easy with the proposed method. It should definitely get you started. But you really need to start reading up on some more algorithms.