i have extracted the number plate from a car, now how can i segment the characters . Need some code. image is attached.

6 views (last 30 days)
I have extracted the number plate from a car. Now, how can I segment the characters? I need some code. The image is attached.
  3 Comments
Ayaz Wazir
Ayaz Wazir on 11 Feb 2018
Edited: Ayaz Wazir on 11 Feb 2018
Dear Abdul Wahab, first see the literature and after that you have to ask about your problem. Their is no way to do direct the desired work
Ibrahim Ismail
Ibrahim Ismail on 5 May 2018
@Ayaz What do you even mean by that? His question was quite simple. If you are asking for help on something, you can surely share your own work as well.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 18 Mar 2017
Your life will be easier if you have the Computer Vision System Toolbox so you can use the built-in OCR. http://www.mathworks.com/help/vision/ref/ocr.html#bt548t1-2_1
  4 Comments
Jan
Jan on 15 Mar 2018
Edited: Jan on 15 Mar 2018
[MOVED from flags] WAQAR RIAZ on 14 Mar 2018 at 8:28. Is there any other way to do it other than ocr?
[Please use flags only to inform admins or editors about inappropriate contents like spam or rudeness. Thanks]

Sign in to comment.

More Answers (2)

KHO KHENG EIAN
KHO KHENG EIAN on 12 Apr 2018
Edited: KHO KHENG EIAN on 12 Apr 2018
Hi, can u share how to extract the number plate from a car?

Image Analyst
Image Analyst on 5 May 2018
If you want to do it traditionally, here is one way:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
% Check that user has the specified Toolbox installed and licensed.
hasLicenseForToolbox = license('test', 'image_toolbox'); % license('test','Statistics_toolbox'), license('test','Signal_toolbox')
if ~hasLicenseForToolbox
% User does not have the toolbox installed, or if it is, there is no available license for it.
% For example, there is a pool of 10 licenses and all 10 have been checked out by other people already.
ver % List what toolboxes the user has licenses available for.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
%===============================================================================
% Read in gray scale demo image.
folder = pwd; % Determine where demo folder is (works with all versions).
baseFileName = 'npidentified.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Display the image.
subplot(2, 3, 1);
imshow(rgbImage, []);
title('Original Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
hp = impixelinfo();
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(rgbImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(rgbImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = rgbImage(:, :, 3); % Take blue channel.
else
grayImage = rgbImage; % It's already gray scale.
end
% Now it's gray scale with range of 0 to 255.
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
title('Original Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
subplot(2, 3, 2);
imhist(grayImage);
grid on;
title('Histogram', 'FontSize', fontSize, 'Interpreter', 'None');
% Convert to logical (binary) with range false and true.
binaryImage = grayImage < 128;
% % Get rid of white surround.
% binaryImage = imclearborder(binaryImage);
% Display the image.
subplot(2, 3, 3);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Do a closing to connect blobs separated in a letter, like the first A.
binaryImage = imclose(binaryImage, true(3));
% Get bounding box sizes
labeledImage = bwlabel(binaryImage);
props = regionprops(binaryImage, 'BoundingBox');
allBB = [props.BoundingBox];
allWidths = allBB(3:4:end)
allHeights = allBB(4:4:end)
% Find blobs that have widths of 20-100, and heights of 50-125.
lettersIndexes = find(allWidths > 20 & allWidths < 100 & allHeights > 20 & allHeights < 125)
binaryImage = ismember(labeledImage, lettersIndexes);
% Display the image.
subplot(2, 3, 4);
imshow(binaryImage, []);
title('Letters Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Take the 6 largest blobs, just in case there are more due to noise.
binaryImage = bwareafilt(binaryImage, 6);
% Display the image.
subplot(2, 3, 5);
imshow(binaryImage, []);
title('Final Letters Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Get bounding box sizes
labeledImage = bwlabel(binaryImage);
props = regionprops(binaryImage, 'BoundingBox');
% Open a new figure window.
figure;
% Extract the bounding boxes with imcrop().
for k = 1 : length(props)
thisBB = props(k).BoundingBox;
subImage = imcrop(binaryImage, thisBB);
subplot(2, 3, k);
imshow(subImage);
end
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!