思路:
1、从点结构变成平行线条结构
2、线条对象
{
x,y,w,v,
area:{
w,
h:1,
s,
e:s,
bg:-1
},
}
3、从线结构提取梯度数据area
4、判断区域area是否为背景
if(area.w>88){
isBg=true
}
5、求最近的背景,识别文字内的背景色
let pre=i-1;
while (pre>=0&&data[pre].y===y&&!data[pre].area.isBg){
pre--
}
6、背景相同,距离相近为同一文字区域
const pos=[x,y,x+w,y,line.area.bg]
pos[4] === rect[4] && dx < 3||dx<2
6、基本识别出大部分文字了,对一、二、三等横行文字再识别
判断横行文字pos[2]-pos[0]>(pos[3]-pos[1])*3&&pos[2]-pos[0]<50
7、输出文字区域和文字颜色
原图