Why it is showing error?
3 views (last 30 days)
Show older comments
close all;
clear all;
im = imread(' Number Plate Images/ image1.png');
imgray = rgb2gray(im);
imbin = imbinarize(imgray);
im = edge(imgray, 'prewitt');
% Below steps are to find location of number plate
Iprops = regionprops(im,'BoundingBox','Area', 'Image');
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
for i = 1:count
if maxa < Iprops(i).Area
maxa = Iprops(i).Area;
boundingBox = Iprops(i).BoundingBox;
end
end
im = imcrop(imbin, boundingBox);
im = bwareaopen(~im, 500);
[h, w] = size(im);
imshow(im);
Iprops = regionprops(im,'BoundingBox','Area', 'Image');
count = numel(Iprops);
noPlate = [];
for i=1:count
ow = length(Iprops(i).Image(1,:));
oh = length(Iprops(i).Image(:,1));
if ow<(h/2) && oh>(h/3)
letter = Letterc(Iprops(i).Image);
noPlate = [noPlate letter];
end
end
.png)
1 Comment
Geoff Hayes
on 11 Oct 2019
Kartikey - is line 20
boundingBox = Iprops(i).BoundingBox;
? It seems fine.. I do wonder about
area = Iprops.Area;
count = numel(Iprops);
maxa= area;
boundingBox = Iprops.BoundingBox;
What are the dimensions of maxa and boundingBox when they are initialized? Are they scalars or arrays? If arrays, will this be a problem when doing the comparison at
if maxa < Iprops(i).Area
?
Answers (1)
Geoff Hayes
on 11 Oct 2019
Kartikey - similar to one of your other questions, there is a special character at the line where you are doing the assignment. If, in Linux, I use cat -t yourFileName.m on the above code, then I see
for i = 1:count
if maxa < Iprops(i).Area
maxa = Iprops(i).Area;
? boundingBox = Iprops(i).BoundingBox;
end
end
that there is a question mark on that line. I would delete this line and re-type the assignment.
0 Comments
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!