2

I am a beginner in Matlab and I am trying to implement a research paper of ANPR Parking System which uses the row projection histogram to identify the horizontal region of the license plates. I have written the following code for calculating the vertical gradients:

Matlab Code:

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

%Calculated the gradients
for i =1:1:rows
    for j =1:1:cols-1
        img2(i,j) = abs(img(i,j+1) - img(i,j));
    end
end

% calculated the mean of gradients to determine which pixels hold the value
% that is above the average difference as the paper says `Then the average
% gradient variance is calculated and compared with each other. The bigger
% intensity variations provide the rough estimation of license plate region.`

M = mean2(img2);
for i =1:1:rows
    for j =1:1:cols-1
        if(abs(img(i,j+1) - img(i,j))<M)
            img2(i,j)=0;
        else
            img2(i,j)=100;
        end
    end
end

% Applied average filter to reduce the noise
img2 = filter2(fspecial('average',2),img2)/255;

% Output is shown
figure,imshow(img2);title('Gradient');

After the gradients calculation, I computed the following histogram:

Horizontal Projection Histogram of the image

Now I need to crop the license plate according to the criteria given in the paper:

Cropping Step shown in the research paper

But I don't know how to crop the image on the basis of the horizontal projection histogram?

I have read some Answers on mathworks and stackoverflow but couldn't find any guidance regarding my issue. Someone please guide me what I need to do to crop the horizontal area as shown in the image. Thanks in advance.

Community
  • 1
  • 1
Itban Saeed
  • 1,660
  • 5
  • 25
  • 38

1 Answers1

0

The discription says "horizontal projection of vertical gradient" . Did you compute the vertical gradient before computing the projection ?

From the looks of the image i think you might have missed this step from another similar question here.

Community
  • 1
  • 1
  • I am sorry I couldn't understand if this answer helps about **cropping the image using the histogram**. I think I haven't missed that step. Please view the updated question, I have added the previous steps to my question. – Itban Saeed Mar 01 '16 at 07:25
  • Well to start with I am not sure what you mean by histogram here. Histogram's give you information about the image and have no relation to location of the pixels . Just their values. Now when you say horizontal projection , in basically means the sum off all pixels in each column. ( I've used variance too for this and it works a little better sometimes ) . So once you perform a horizontal projection you will get a vector . This vector will give help you identify crop points for the number plate. – Midhun Harikumar Mar 01 '16 at 22:19