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
我想从文本文档中提取行。我可以通过对其列求和并生成一维向量来实现这一点(这将是图像的水平投影)。这是图像
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
如果我绘制这个,我可以看到零值显示空白,峰值描绘了线条。这是情节
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
所以看一下情节(和数组),我可以看出第三行来自数组索引129:184。所以提取它我做了这个
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.
它似乎没有像我做imshow(测试)或imshow(test,[])那样工作。它给出了以下结果。不完全是第三行。
What am I doing wrong here?
我在这做错了什么?
1 个解决方案
#1
1
You want to display the 2D image rather than 1D line:
您想要显示2D图像而不是1D行:
imshow(img(129:184,:))
gives you line 129 - 184.
给你129-184行。
#1
1
You want to display the 2D image rather than 1D line:
您想要显示2D图像而不是1D行:
imshow(img(129:184,:))
gives you line 129 - 184.
给你129-184行。