Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
ezhil K
ezhil K am 31 Jan. 2019
Kommentiert: ezhil K am 31 Jan. 2019
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

Antworten (1)

KSSV
KSSV am 31 Jan. 2019
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 Kommentare
KSSV
KSSV am 31 Jan. 2019
Bearbeitet: KSSV am 31 Jan. 2019
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 am 31 Jan. 2019
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by