suppose i have an image in which there are some letters.based on those letters of the image i want to show the vertical projections of histogram of the given image in an axes:
i tried imhist('image')
但它没有显示投影,它只在我的 GUI 轴上给出一个白框
a=imhist(Iedge2);
imshow(a,'Parent',handles.axes2);
title('HISTOGRAM OF DILATED IMAGE')
in this iedge2
是反转的二值图像。
获得垂直直方图后,我想将倒置的二值图像分割成垂直段,作为句子的单词/单词的字母,其中白色像素较少或没有
我不知道该怎么做,请帮忙先生,应用您的代码后我得到以下输出
i have combined the screenshots in a single snapshot so that will be easy to u to see in a single image of outputs
首先,你是not寻找“垂直直方图”,而是寻找“垂直直方图”bar plot的垂直总和。
这是一个简化的示例。
Consider this input image
您可以阅读并设置阈值
img = imread('https://i.stack.imgur.com/3YonG.png')
bw = img(:,:,1)<128; %// convert to binary, text = 1
现在您可以检查垂直总和
sc = sum(bw,1); %// sum columns
figure;bar(sc);
正如您所看到的,如果一列中设置了超过 2 个像素 - 这可能是一个字母。我们可以使用这个阈值
rm = sc > 2;
cs = cumsum(~rm).*rm; %// assign unique value to each "letter" columns
mask = bsxfun(@times, bw, cs ); %// seperate the letters in the mask
结果是
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)