i want to extract lines from a text document. I can accomplish this by summing its columns and produce a 1 dimensional vector (This will be the horizontal projection of the image). This is the image enter image description here

img = imcomplement(rgb2gray(imread('french.jpg')));
lines = sum(img, 2);
plot(lines);

If I plot this I can see that the zero values show the blank spaces and the peaks depict the lines. Here is the plot

enter image description here

So looking at the plot (and the array) I can tell that the third line is from array index 129:184. So to extract it I did this

test = lines(129:184);

It does not seem to work as if I do imshow(test) or imshow(test, []) It gives the following result. Not exactly the third line.

enter image description here

What am I doing wrong here?

有帮助吗?

解决方案

You want to display the 2D image rather than 1D line:

imshow(img(129:184,:)) 

gives you line 129 - 184.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top