필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by