Why it is showing error?

2 ビュー (過去 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 Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by