Segment numbers in the image - Matlab

I have a license plate image in black and white.

this is how it looks:

enter image description here

Now I want to color the background of each digit, for further work cutting off the numbers from the plate.

like this:

enter image description here

Any help would be greatly appreciated.

+6
image-processing matlab
source share
2 answers

One easy way to create your boxes is to sum your image down each column and look for where the sum falls below a certain threshold (i.e. where white pixels drop below a given number in this column). This will give you the indices of the columns where the fields should be. The width of these cells may be too narrow (i.e., small parts of the digits may protrude sides), so you can expand the edges by folding the index vector with a small unit vector and search for resulting values ​​greater than zero. Here is an example of using your image above:

rawImage = imread('license_plate.jpg'); %# Load the image maxValue = double(max(rawImage(:))); %# Find the maximum pixel value N = 35; %# Threshold number of white pixels boxIndex = sum(rawImage) < N*maxValue; %# Find columns with fewer white pixels boxImage = rawImage; %# Initialize the box image boxImage(:,boxIndex) = 0; %# Set the indexed columns to 0 (black) dilatedIndex = conv(double(boxIndex),ones(1,5),'same') > 0; %# Dilate the index dilatedImage = rawImage; %# Initialize the dilated box image dilatedImage(:,dilatedIndex) = 0; %# Set the indexed columns to 0 (black) %# Display the results: subplot(3,1,1); imshow(rawImage); title('Raw image'); subplot(3,1,2); imshow(boxImage); title('Boxes placed over numbers'); subplot(3,1,3); imshow(dilatedImage); title('Dilated boxes placed over numbers'); 

enter image description here

Note. The above threshold value suggests that a black and white image can be of type double (with values ​​0 or 1), logical (also with values ​​0 or 1), or an 8-bit unsigned integer (with values ​​0 or 255). All you have to do is set N to the number of white pixels to use as a threshold for identifying a column containing part of the number.

+7
source share

Assuming you have a field surrounding the letters, giving you a common angle

Minimize the image 1d (may help to rotate it first so that the bounding box is horizontal)

Then find the spaces between the letters in this 1st signature, indicating the position of the numbers. This helps if you know the number of digits and the format for the plates.

0
source share

All Articles