【问题标题】:segmentation of characters row using Horizontal histogram profile [duplicate]使用水平直方图轮廓分割字符行[重复]
【发布时间】:2016-10-04 17:04:24
【问题描述】:

我想从图像中分割出水平行的字符,如图所示

clear all;
cd('C:\Users\IFIM\Desktop\New folder\KANND_HAND_SET');
myFolder = 'C:\Users\IFIM\Desktop\segment';
[filename, pathname] = uigetfile('*.bmp','Select image to be read.');
i= imread(fullfile(pathname,filename));
i=padarray(i,[0 10]);
verticalProjection = sum(i, 1);
set(gcf, 'Name', 'DEMO BY SOUMYADEEP', 'NumberTitle', 'Off') 
subplot(2, 2, 1);imshow(i); 
subplot(2,2,3);
plot(verticalProjection, 'b-');
grid on;
t = verticalProjection;
t(t==0) = inf;
mayukh=min(t)
% 0 where there is background, 1 where there are letters
letterLocations = verticalProjection > mayukh; 
% Find Rising and falling edges
d = diff(letterLocations);
startingColumns = find(d>0);
endingColumns = find(d<0);
% Extract each region
y=1;
for k = 1 : length(startingColumns)
  % Get sub image of just one character...
  subImage = i(:, startingColumns(k):endingColumns(k)); 
[L,num] = bwlabel(subImage);
for z= 1 : num
bw= ismember( L, z);
% Construct filename for this particular image.
baseFileName = sprintf('curvedimage %d.png', y);
 y=y+1;
% Prepend the folder to make the full file name.
fullFileName = fullfile(myFolder, baseFileName);
% Do the write to disk.
imwrite(bw, fullFileName);
subplot(2,2,4);
pause(2);
imshow(bw);
end;
y=y+1;
end;

在这段代码中,垂直分割正在发生,但我想要的是从段落中获取水平线,以便在请帮助后完成垂直分割 谢谢和问候

【问题讨论】:

    标签: matlab image-processing histogram image-segmentation


    【解决方案1】:

    您需要先清理一下您的图像以简化操作。尝试以下方法:

    1. opening(删除小的隔离组件)。 Result
    2. closing(重新连接关闭组件)。 Result
    3. (可选)连接组件标签以分隔每个字母(您以后肯定会需要它)
    4. 然后,您可以使用更容易分析的直方图投影。您应该在信号中看到与行一样多的峰值。
    5. (可选)如果直方图不够清晰,请使用中值滤波器和高斯滤波器,以对信号进行去噪和平滑处理。

    【讨论】:

    • 请根据您的要求更新此代码,因为我不明白您告诉我要正确做什么
    • 我添加了指向 MatLab 操作的链接和指向结果的链接。
    • 感谢先生帮助我从图像中删除错误,但我想要的是在我上传代码时从手写字符图像中分割水平线,这是用于垂直分割的,请帮助我进行更改上面的代码,以便它也可以用于裁剪线
    • 首先,计算我预处理过的图像的水平直方图。您会看到直方图更加清晰。事实上,直方图不为空的唯一时刻是因为您要查找的行。
    • 先生,我得到了干净的直方图,我正在根据这个编辑我的问题,你能帮我根据我的图像更正这个代码吗???
    猜你喜欢
    • 1970-01-01
    • 2018-01-06
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 2017-05-15
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    相关资源
    最近更新 更多