资源简介
该方法使用Rosenfeld 细化算法,注释详细,阅读方便。
代码片段和文件信息
//********************************************************//
//Updated By Rg1949/10/01
//该方法是基于opencv 中Mat 类的
//
//细化汉字图像,提取汉字骨架,
//f:规范化汉字源图像,flag:细化选择参数
void charFeatures::thinnerRosenfeld(Mat &charMat Mat &thinnerMat)
{
int lx = charMat.cols; int ly = charMat.rows;
Mat tMat(charMat.rows charMat.cols CV_8UC1);
uchar *f = tMat.data;
uchar *g;
int *n = new int[10];
int a[5] = { 0 -1 1 0 0 };
int b[5] = { 0 0 0 1 -1 };
int nrnd cond n48 n26 n24 n46 n68 n82 n123 n345 n567 n781;
int k shori;
int i j;
int ii jj kk kk1 kk2 kk3 size;
size = lx * ly;
g = new uchar[size];
for (int i = 0; i < size; i++) {
if (charMat.data[i] == 0)
f[i] = 1;
else
f[i] = 0;
}
for (j = 0; j f[j] = 0;
for (j = 0; j f[(ly - 1) * lx + j] = 0;
for (i = 0; i f[lx * i] = 0;
for (i = 0; i f[lx * i + lx - 1] = 0;
for (kk = 0; kk {
g[kk] = f[kk];
}
do
{
//r_num++;
shori = 0;
for (k = 1; k <= 4; k++)
{
for (i = 1; i {
ii = i + a[k];
for (j = 1; j {
kk = i*ly + j;
if (f[kk] == 0)
continue;
jj = j + b[k];
kk1 = ii*ly + jj;
if (f[kk1] == 1)
continue;
kk1 = kk - ly - 1;
kk2 = kk1 + 1;
kk3 = kk2 + 1;
n[3] = f[kk1];
n[2] = f[kk2];
n[1] = f[kk3];
kk1 = kk - 1;
kk3 = kk + 1;
n[4] = f[kk1];
n[8] = f[kk3];
kk1 = kk + ly - 1;
- 上一篇:adsl.zip
- 下一篇:GrandDog宏狗驱动
评论
共有 条评论