코드에서 :말씀 분할 MATLAB
img = imread ('G:\Stuff\RP\Database\0001_4.jpg');
%imshow(img);
bin_img = imcomplement(im2bw(img, 0.8)); %Binarizing
%figure;
%imshow(bin_img);
bin_img = bwareaopen(bin_img, 50); %for removing dots and commas
%%%%%%%% Line Segmentation %%%%%%%%
dbw_img = imdilate(bin_img, strel('line', 100, 0));%Dilating
[L, N]=bwlabel(dbw_img); %finding connected components
bbox = regionprops(L, 'BoundingBox');
lineSlopeMatrix=[N 0];
for i=1:N %must run for all the lines in an image
bBox=bbox(i).BoundingBox;
x=bBox(1)+0.5;
y=bBox(2)+0.5;
w=bBox(3);
h=bBox(4);
linePatch=bin_img(y:y+h,:); %Extracting line
figure,imshow(linePatch) % Prints lines
words_img = imdilate(linePatch, strel('line', 40, 0));%Dilating
[R, C]=bwlabel(words_img); %finding connected components i.e. Words
bounding = regionprops(R, 'BoundingBox');
for j=1:C %nmust run for the words in a line
bdBox=bounding(j).BoundingBox;
xAxis=bdBox(1)+0.5;
yAxis=bdBox(2)+0.5;
width=bdBox(3);
height=bdBox(4);
% [row col]=size(linePatch)
% yAxis,yAxis+height,xAxis,xAxis+width
Patch=linePatch(yAxis:yAxis+height,xAxis:xAxis+width);
%Extracting Patch of Words
figure,imshow(Patch) %Prints words
Patch=[];
end
linePatch=[];
end
문제 : 내가 처음 그 라인에서 단어를 추출 입력 이미지에서 선을 분할하고. 올바르게 (포스트와 연결된 입력 화상에서) 제 라인 밖으로 내 ALGO 세그먼트는 단어, 다음과 같은 세그먼트는 저 다음 오류를 범보다 번째 행에서 첫번째 단어 :
??? Index exceeds matrix dimensions.
Error in ==> test_words_lines at 33
Patch=linePatch(yAxis:yAxis+height,xAxis:xAxis+width);
I가 이해 Segmentation of Words from Line 1 // Segmentation of Words from Line 2
0 : 오류가 쉽게 행렬의 크기를 확인,는 사진이 부착 된 보입니까 .. 그들은 잘 보이거나 어쩌면 나는이 문제를 찾을 수 없습니다
이 오류의 올바른 원인을 알려 수정 조치를 제안하십시오.
디버거를 사용하고'Patch = linePatch (yAxis : yAxis + height, xAxis : xAxis + width)'행에서 중지하십시오. 'xAxis, yAxis, 등 '의 값을 확인하십시오. 행렬'linePatch'의 크기보다 큰가요? – bushmills
'height','width','yAxis'와'linePatch'의 크기 는요? – bushmills
@bushmills 조건 'i == 2 && j == 2'로 중단 점을 추가하고'xAxis'의 값이 280,'yAxis' 104,'width'가 45,'height' 'linePatch'는 108 * 2465입니다. 이제,'yAxis + height' = 104 + 5 = 109, 이는 행의 108보다 큰데 ..하지만 이해가되지 않습니다 ..'size (linePatch) = 108 * 2465'는 108 행을 나타내지 않고 2465 열? 및 'xAxis'및 'yAxis'값은 픽셀 번호? 미리 감사드립니다 :) –