フィルターのクリア

How to resolve the error "Index exceeds array bounds" in matlab?

1 回表示 (過去 30 日間)
ezhil K
ezhil K 2019 年 1 月 31 日
コメント済み: ezhil K 2019 年 1 月 31 日
I need to extract the characters in the image.But,I get error.I have attached my code below.I need to extract all the characters in my image.Can anyone please help me in rectifying my error.
My error is:
Index exceeds array bounds.
Error in te (line 6)
word = results.Words{2};
% Load an image
I = imread('test3.png');
% Perform OCR
results = ocr(I);
% Display one of the recognized words
word = results.Words{2};
test3.png

回答 (1 件)

KSSV
KSSV 2019 年 1 月 31 日
Please check the variable:
results.Words
It is empty in your case.....ocr didnot capture any words.......As the variable is empty..you are getting an error.
  3 件のコメント
KSSV
KSSV 2019 年 1 月 31 日
編集済み: KSSV 2019 年 1 月 31 日
Can you tell me what does
results.words
outputs? It is an empty cell. ocr doesnt throw any error it doesn't mean, it could capture the characters.
ezhil K
ezhil K 2019 年 1 月 31 日
So how should I capture the characters.I have segmented all the characters from my image.Now,how should I capture the characters from it?My character segmentation code is attached below.Now how should I identify the segmented characters.I have attached my input image also.
clear all;
close all;
I = imread('test3.png');
BW = im2bw(I, 0.9);
BW = ~BW;
stats = regionprops(BW);
for index=1:length(stats)
if stats(index).Area > 200 && stats(index).BoundingBox(3)*stats(index).BoundingBox(4) < 30000
x = ceil(stats(index).BoundingBox(1))
y= ceil(stats(index).BoundingBox(2))
widthX = floor(stats(index).BoundingBox(3)-1)
widthY = floor(stats(index).BoundingBox(4)-1)
subimage(index) = {BW(y:y+widthY,x:x+widthX,:)};
figure, imshow(subimage{index})
end
end
test3.png

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by