Borrar filtros
Borrar filtros

Undefined function 'readLetter' for input arguments of type 'logical'.

1 visualización (últimos 30 días)
Praveen  kumar
Praveen kumar el 20 de Mzo. de 2016
Comentada: Walter Roberson el 21 de Mzo. de 2016
%NUMBERPLATEEXTRACTION extracts the characters from the input number plate image.
f=imread('car3.jpg'); % Reading the number plate image.
f=imresize(f,[400 NaN]); % Resizing the image keeping aspect ratio same.
g=rgb2gray(f); % Converting the RGB (color) image to gray (intensity).
g=medfilt2(g,[3 3]); % Median filtering to remove noise.
se=strel('disk',1); % Structural element (disk of radius 1) for morphological processing.
gi=imdilate(g,se); % Dilating the gray image with the structural element.
ge=imerode(g,se); % Eroding the gray image with structural element.
gdiff=imsubtract(gi,ge); % Morphological Gradient for edges enhancement.
gdiff=mat2gray(gdiff); % Converting the class to double.
gdiff=conv2(gdiff,[1 1;1 1]); % Convolution of the double image for brightening the edges.
gdiff=imadjust(gdiff,[0.5 0.7],[0 1],0.1); % Intensity scaling between the range 0 to 1.
B=logical(gdiff); % Conversion of the class from double to binary.
% Eliminating the possible horizontal lines from the output image of regiongrow
% that could be edges of license plate.
er=imerode(B,strel('line',50,0));
out1=imsubtract(B,er);
% Filling all the regions of the image.
F=imfill(out1,'holes');
% Thinning the image to ensure character isolation.
H=bwmorph(F,'thin',1);
H=imerode(H,strel('line',3,90));
% Selecting all the regions that are of pixel area more than 100.
final=bwareaopen(H,100);
% final=bwlabel(final); % Uncomment to make compitable with the previous versions of MATLAB®
% Two properties 'BoundingBox' and binary 'Image' corresponding to these
% Bounding boxes are acquired.
Iprops=regionprops(final,'BoundingBox','Image');
% Selecting all the bounding boxes in matrix of order numberofboxesX4;
NR=cat(1,Iprops.BoundingBox);
% Calling of controlling function.
r=controlling(NR); % Function 'controlling' outputs the array of indices of boxes required for extraction of characters.
if ~isempty(r) % If succesfully indices of desired boxes are achieved.
I={Iprops.Image}; % Cell array of 'Image' (one of the properties of regionprops)
noPlate=[]; % Initializing the variable of number plate string.
for v=1:length(r)
N=I{1,r(v)}; % Extracting the binary image corresponding to the indices in 'r'.
letter=readLetter(N); % Reading the letter corresponding the binary image 'N'.
while letter=='O' || letter=='0' % Since it wouldn't be easy to distinguish
if v<=3 % between '0' and 'O' during the extraction of character
letter='O'; % in binary image. Using the characteristic of plates in Karachi
else % that starting three characters are alphabets, this code will
letter='0'; % easily decide whether it is '0' or 'O'. The condition for 'if'
end % just need to be changed if the code is to be implemented with some other
break; % cities plates. The condition should be changed accordingly.
end
noPlate=[noPlate letter]; % Appending every subsequent character in noPlate variable.
end
fid = fopen('noPlate.txt', 'wt'); % This portion of code writes the number plate
fprintf(fid,'%s\n',noPlate); % to the text file, if executed a notepad file with the
fclose(fid); % name noPlate.txt will be open with the number plate written.
winopen('noPlate.txt')
% Uncomment the portion of code below if Database is to be organized. Since my
% project requires database so I have written this code. DB is the .mat
% file containing the array of structure of all entries of database.
% load DB
% for x=1:length(DB)
% recordplate=getfield(DB,{1,x},'PlateNumber');
% if strcmp(noPlate,recordplate)
% disp(DB(x));
% disp('*-*-*-*-*-*-*');
% end
% end
else % If fail to extract the indexes in 'r' this line of error will be displayed.
fprintf('Unable to extract the characters from the number plate.\n');
fprintf('The characters on the number plate might not be clear or touching with each other or boundries.\n');
end
end
error:
numberPlateExtraction
Error using fprintf
Invalid file identifier. Use fopen
  7 comentarios
Walter Roberson
Walter Roberson el 21 de Mzo. de 2016
Is the current error still about readLetter? If so then is the readLetter that you have on your MATLAB path?
which readLetter
Or is the error you are working on now the one about invalid file identifier? If so then please show us the result of
pwd

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Mzo. de 2016
readLetter is part of http://www.mathworks.com/matlabcentral/fileexchange/44088-car-license-plate-reader or http://www.mathworks.com/matlabcentral/fileexchange/40426-vehicle-number-plate-recognition . You need to download one of those two .zip files, and unzip them into a convenient directory that is not under your MATLAB installation directory, and then use the MATLAB command pathtool to add the directory to the MATLAB path; remember to tell pathtool to "save" the path afterwards. After that, your code will be able to find readLetter .

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by