Why it is showing error?

3 次查看(过去 30 天)
Kartikey Rai
Kartikey Rai 2019-10-11
回答: Geoff Hayes 2019-10-11
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
Screenshot (38).png
  1 个评论
Geoff Hayes
Geoff Hayes 2019-10-11
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
?

请先登录,再进行评论。

回答(1 个)

Geoff Hayes
Geoff Hayes 2019-10-11
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.

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by