📄 fingerdlg.cpp
字号:
direct[8*i+l][8*j+m]=dir;
}
}
}
////////////////////////////////
/* for(int l=0;l<22;l++) //消除边框;
for(int m=0;m<300;m++)
{
data[l][m]=255;
data[m][l]=255;
}
for(int aa=278;aa<301;aa++)
for(int b=0;b<300;b++)
{
data[aa][b]=255;
data[b][aa]=255;
}*/
//////////////
ShowBmp();
return 0;
}
long CFingerDlg::delalate()
{
int j;//行变量;
int i;//列变量;
static int S_he;
Sequency S[8];
Sequency temp;
int data_temp[300][300];
int p_1[4],p_2[4],p_3[4],p_4[4],p_5[4],p_6[4],p_7[4],p_8[4];//用于存储方向信息;
for(j=4;j<296;j++)
{
for(i=4;i<296;i++)
{
p_1[0]=data[j-4][i];
p_1[1]=data[j-2][i];
p_1[2]=data[j+2][i];
p_1[3]=data[j+4][i];
//////////////////////////////////////////
p_2[0]=data[j-4][i+2];
p_2[1]=data[j-2][i+1];
p_2[2]=data[j+2][i-1];
p_2[3]=data[j+4][i-2];
//////////////////////////////////////////
p_3[0]=data[j-4][i+4];
p_3[1]=data[j-2][i+2];
p_3[2]=data[j+2][i-2];
p_3[3]=data[j+4][i-4];
//////////////////////////////////////////
p_4[0]=data[j-2][i+4];
p_4[1]=data[j-1][i+2];
p_4[2]=data[j+1][i-2];
p_4[3]=data[j+2][i-4];
//////////////////////////////////////////
p_5[0]=data[j][i+4];
p_5[1]=data[j][i+2];
p_5[2]=data[j][i-2];
p_5[3]=data[j][i-4];
///////////////////////////////////////////
p_6[0]=data[j+2][i+4];
p_6[1]=data[j+1][i+2];
p_6[2]=data[j-1][i-2];
p_6[3]=data[j-2][i-4];
///////////////////////////////////////////
p_7[0]=data[j+4][i+4];
p_7[1]=data[j+2][i+2];
p_7[2]=data[j-2][i-2];
p_7[3]=data[j-4][i-4];
////////////////////////////////////////////
p_8[0]=data[j+4][i+2];
p_8[1]=data[j+2][i+1];
p_8[2]=data[j-2][i-1];
p_8[3]=data[j-4][i-2];//方向量求解完毕;
//计算掩模参数S
for(int n=0;n<8;n++)
{
S[n].No=n;
S[n].Number=0;
}
S[0].Number=p_1[0]+p_1[1]+p_1[2]+p_1[3];
S[1].Number=p_2[0]+p_2[1]+p_2[2]+p_2[3];
S[2].Number=p_3[0]+p_3[1]+p_3[2]+p_3[3];
S[3].Number=p_4[0]+p_4[1]+p_4[2]+p_4[3];
S[4].Number=p_5[0]+p_5[1]+p_5[2]+p_5[3];
S[5].Number=p_6[0]+p_6[1]+p_6[2]+p_6[3];
S[6].Number=p_7[0]+p_7[1]+p_7[2]+p_7[3];
S[7].Number=p_8[0]+p_8[1]+p_8[2]+p_8[3];
S_he=S[0].Number+S[1].Number+S[2].Number+S[3].Number+S[4].Number+S[5].Number+S[6].Number+S[7].Number;
//对八个掩模参数进行排序
for(int x=1;x<8;x++)
{
for(int y=0;y<8-x;y++)
{
if(S[y].Number>S[y+1].Number)
{
temp=S[y];
S[y]=S[y+1];
S[y+1]=temp;
}
}
}
//进行前景和背景分割
if((3*data[j][i]+S[0].Number+S[7].Number)>=(S_he*3/8)&&S_he!=0)
data_temp[j][i]=255;
else
data_temp[j][i]=data[j][i];
}
}
for(j=0;j<300;j++)
{
for(i=0;i<300;i++)
{
data[j][i]=data_temp[j][i];
}
}
ShowBmp();
return 0;
}
long CFingerDlg::directfilter()
{
// TODO: Add your control notification handler code here
int conclution;
for (int i=6;i<294;i++)
{
for(int j=6;j<294;j++)
{
if(direct[i][j]==0)//0度滤波;
{
conclution=data[i][j-3]+data[i][j-2]+data[i][j-1]+data[i][j+1]+data[i][j+2]
+data[i][j+3]+data[i-1][j-1]+data[i-1][j]+data[i-1][j+1]+data[i+1][j-1]
+data[i+1][j]+data[i+1][j+1];
if(data[i][j]==255)
{
if(conclution<=255*5)
{
data[i][j]=0;
}
}
if(data[i][j]==0)
{
if(conclution>255*6)
{
data[i][j]=255;
}
}
}
if(direct[i][j]==1)//135度滤波;
{
conclution=data[i+2][j-2]+data[i+2][j-1]+data[i+1][j-2]+data[i+1][j-1]+data[i+1][j]
+data[i][j-1]+data[i][j+1]+data[i-1][j]+data[i-1][j+1]+data[i-1][j+2]
+data[i-2][j+1]+data[i-2][j+2];
{
if(conclution<=255*2)
{
data[i][j]=0;
}
}
if(data[i][j]==0)
{
if(conclution>=255*8)
{
data[i][j]=255;
}
}
}
if(direct[i][j]==2)//90度滤波
{
conclution=data[i-1][j-1]+data[i][j-1]+data[i+1][j-1]+data[i-3][j]+data[i-2][j]
+data[i-1][j]+data[i+1][j]+data[i+2][j]+data[i+3][j]+data[i-1][j+1]
+data[i][j+1]+data[i+1][j+1];
if(conclution<255*6)
data[i][j]=0;
if(conclution>255*6)
data[i][j]=255;
}
if(direct[i][j]==3)//45度滤波;
{
conclution=data[i-2][j-2]+data[i-2][j-1]+data[i-1][j-2]+data[i-1][j-1]+data[i-1][j]
+data[i][j-1]+data[i][j+1]+data[i+1][j]+data[i+1][j+1]+data[i+1][j+2]
+data[i+2][j+1]+data[i+2][j+2];
if(data[i][j]==255)
{
if(conclution<=255*2)
{
data[i][j]=0;
}
}
if(data[i][j]==0)
{
if(conclution>=255*8)
{
data[i][j]=255;
}
}
}
}
}
ShowBmp();
return 0;
}
long CFingerDlg::directmid()
{
// TODO: Add your control notification handler code here
int nei[3][3];
int nei_pai[19];
int temp;
for (int i=12;i<288;i++)
{
for(int j=12;j<288;j++)
{
for(int m=0;m<3;m++)
{
for(int n=0;n<3;n++)
{
nei[m][n]=data[i+m-1][j+n-1];
}
}
if(direct[i][j]==0)//0
{
nei_pai[0]=nei[0][0];
nei_pai[1]=nei[0][0];
nei_pai[2]=nei[0][1];
nei_pai[3]=nei[0][2];
nei_pai[4]=nei[0][2];
nei_pai[5]=nei[1][0];
nei_pai[6]=nei[1][0];
nei_pai[7]=nei[1][1];
nei_pai[8]=nei[1][1];
nei_pai[9]=nei[1][1];
nei_pai[10]=nei[1][1];
nei_pai[11]=nei[1][2];
nei_pai[12]=nei[1][2];
nei_pai[13]=nei[1][2];
nei_pai[14]=nei[2][0];
nei_pai[15]=nei[2][0];
nei_pai[16]=nei[2][1];
nei_pai[17]=nei[2][2];
nei_pai[18]=nei[2][2];
for(int x=1;x<19;x++)
{
for(int y=0;y<19-x;y++)
{
if(nei_pai[y]>nei_pai[y+1])
{
temp=nei_pai[y];
nei_pai[y]=nei_pai[y+1];
nei_pai[y+1]=temp;
}
}
}
data[i][j]=nei_pai[9];
}
if(direct[i][j]==2)//90
{
nei_pai[0]=nei[0][0];
nei_pai[1]=nei[0][0];
nei_pai[2]=nei[0][1];
nei_pai[3]=nei[0][1];
nei_pai[4]=nei[0][1];
nei_pai[5]=nei[0][2];
nei_pai[6]=nei[0][2];
nei_pai[7]=nei[1][0];
nei_pai[8]=nei[1][1];
nei_pai[9]=nei[1][1];
nei_pai[10]=nei[1][1];
nei_pai[11]=nei[1][2];
nei_pai[12]=nei[2][0];
nei_pai[13]=nei[2][0];
nei_pai[14]=nei[2][1];
nei_pai[15]=nei[2][1];
nei_pai[16]=nei[2][1];
nei_pai[17]=nei[2][2];
nei_pai[18]=nei[2][2];
for(int x=1;x<19;x++)
{
for(int y=0;y<19-x;y++)
{
if(nei_pai[y]>nei_pai[y+1])
{
temp=nei_pai[y];
nei_pai[y]=nei_pai[y+1];
nei_pai[y+1]=temp;
}
}
}
data[i][j]=nei_pai[9];
}
if(direct[i][j]==1)//135
{
nei_pai[0]=nei[0][0];
nei_pai[1]=nei[0][1];
nei_pai[2]=nei[0][1];
nei_pai[3]=nei[0][2];
nei_pai[4]=nei[0][2];
nei_pai[5]=nei[0][2];
nei_pai[6]=nei[1][0];
nei_pai[7]=nei[1][0];
nei_pai[8]=nei[1][1];
nei_pai[9]=nei[1][1];
nei_pai[10]=nei[1][1];
nei_pai[11]=nei[1][2];
nei_pai[12]=nei[1][2];
nei_pai[13]=nei[2][0];
nei_pai[14]=nei[2][0];
nei_pai[15]=nei[2][0];
nei_pai[16]=nei[2][1];
nei_pai[17]=nei[2][1];
nei_pai[18]=nei[2][2];
for(int x=1;x<19;x++)
{
for(int y=0;y<19-x;y++)
{
if(nei_pai[y]>nei_pai[y+1])
{
temp=nei_pai[y];
nei_pai[y]=nei_pai[y+1];
nei_pai[y+1]=temp;
}
}
}
data[i][j]=nei_pai[9];
}
if(direct[i][j]==3)//45
{
nei_pai[0]=nei[0][0];
nei_pai[1]=nei[0][0];
nei_pai[2]=nei[0][0];
nei_pai[3]=nei[0][1];
nei_pai[4]=nei[0][1];
nei_pai[5]=nei[0][2];
nei_pai[6]=nei[1][0];
nei_pai[7]=nei[1][0];
nei_pai[8]=nei[1][1];
nei_pai[9]=nei[1][1];
nei_pai[10]=nei[1][1];
nei_pai[11]=nei[1][2];
nei_pai[12]=nei[1][2];
nei_pai[13]=nei[2][0];
nei_pai[14]=nei[2][1];
nei_pai[15]=nei[2][1];
nei_pai[16]=nei[2][2];
nei_pai[17]=nei[2][2];
nei_pai[18]=nei[2][2];
for(int x=1;x<19;x++)
{
for(int y=0;y<19-x;y++)
{
if(nei_pai[y]>nei_pai[y+1])
{
temp=nei_pai[y];
nei_pai[y]=nei_pai[y+1];
nei_pai[y+1]=temp;
}
}
}
data[i][j]=nei_pai[9];
}
}
}
return 0;
}
long CFingerDlg::getendandstart()
{
// TODO: Add your control notification handler code here
int bcount;
int i,j;
int a[9];
int v;
int count;
for(i=0;i<300;i++)
{
for(j=0;j<300;j++)
{
show[i][j]=255;
mart[i][j]=255;
}
}
for(i=1;i<299;i++)
{
for(j=1;j<299;j++)
{
if(data[i][j]<10)
{
bcount=0;
if(data[i+1][j]<10)
{
a[0]=0;
bcount++;
}
else
a[0]=1;
if(data[i+1][j+1]<10)
{
a[1]=0;
bcount++;
}
else
a[1]=1;
if(data[i][j+1]<10)
{
a[2]=0;
bcount++;
}
else
a[2]=1;
if(data[i-1][j+1]<10)
{
a[3]=0;
bcount++;
}
else
a[3]=1;
if(data[i-1][j]<10)
{
a[4]=0;
bcount++;
}
else
a[4]=1;
if(data[i-1][j-1]<10)
{
a[5]=0;
bcount++;
}
else
a[5]=1;
if(data[i][j-1]<10)
{
a[6]=0;
bcount++;
}
else
a[6]=1;
if(data[i+1][j-1]<10)
{
a[7]=0;
bcount++;
}
else
a[7]=1;
a[8]=a[0];
count=0;
for(v=0;v<8;v++)
{
if(a[v+1]!=a[v])
count++;
}
if(count==2)
{
show[i][j]=0;//////////////////终结点
}
if(count==6||count==8)//////////////表示分叉点
{
show[i][j]=5;
}
}
}
}
for(i=0;i<20;i++)
{
for(j=0;j<300;j++)
{
show[i][j]=255;
show[i+280][j]=255;
}
}
for(i=0;i<20;i++)
{
for(j=0;j<300;j++)
{
show[j][i]=255;
show[j][i+280]=255;
}
}
for(i=0;i<300;i++)
{
for(j=0;j<300;j++)
{
mart[i][j]=show[i][j];
}
}
return 0;
}
long CFingerDlg::chargezabo()
{
// TODO: Add your control notification handler code here
shan();
return 0;
}
long CFingerDlg::chargekongdong()
{
// TODO: Add your control notification handler code here
shankong(0,0);
return 0;
}
int CFingerDlg::shan()
{
int i,j;
int t1;
//////////////////
for(i=20;i<280;i++)
{
for(j=20;j<280;j++)
{
if(mart[i][j]==0)
{
t1=testlen(i,j);
}
}
}
return 0;
}
int CFingerDlg::shankong(int a, int b)
{
int i,j;
for(i=20;i<280;i++)
{
for(j=20;j<280;j++)
{
if(show[i][j]==5)
{
bijiao(i,j);
getendandstart();
}
}
}
return 0;
}
int CFingerDlg::testlen(int a, int b)
{
////////////////////////
int t;
int za;
int minlen;
int mid,midx,midy;
int len;
int flag;
int nextx,nexty;
int lenght;
int i,j;
//////////////////////////
minlen=10;
mid=5;
len=30;
lenght=0;
flag=1;
i=a;
j=b;
nextx=i;
nexty=j;
//0表示没有占用的终结点,1表示被占用的终结点,5表示没有被占用的分叉点,6表示被占用的分叉点;
while(flag==1)//////////
{
t=searcharendpoint(i,j,a,b);
if(t==1)
{
flag=0;
}
else
{
if(data[i+1][j]<10 &&show[i+1][j]==255)
{
nextx=i+1;
nexty=j;
lenght++;
show[i+1][j]=20;
}///////////扫描一点;
else
{
if(data[i-1][j]<10 &&show[i-1][j]==255)
{
nextx=i-1;
nexty=j;
lenght++;
show[i-1][j]=20;
}///////////////////扫描二点
else
{
if(data[i][j+1]<10 && show[i][j+1]==255)
{
nextx=i;
nexty=j+1;
lenght++;
show[i][j+1]=20;
}////////////////扫描三点;
else
{
if(data[i][j-1]<10 &&show[i][j-1]==255)
{
nextx=i;
nexty=j-1;
flag=1;
lenght++;
show[i][j-1]=20;
}/////////////////扫描四点;
else
{
if(data[i-1][j-1]<10&&show[i-1][j-1]==255)
{
nextx=i-1;
nexty=j-1;
flag=1;
lenght++;
show[i-1][j-1]=20;
}///////////////////扫描五点;
else
{
if(data[i-1][j+1]<10 &&show[i-1][j+1]==255)
{
nextx=i-1;
nexty=j+1;
flag=1;
lenght++;
show[i-1][j+1]=20;
}/////////////////////扫描六点;
else
{
if(data[i+1][j-1]<10 &&show[i+1][j-1]==255)
{
nextx=i+1;
nexty=j-1;
flag=1;
lenght++;
show[i+1][j-1]=20;
}/////////////////////扫描七点;
else
{
if(data[i+1][j+1]<10 &&show[i+1][j+1]==255)
{
nextx=i+1;
nexty=j+1;
flag=1;
lenght++;
show[i+1][j+1]=20;
}////////////////扫描八点
else
{
flag=0;
}
}
}
}
}
}
}
}
}
i=nextx;
j=nexty;
if(lenght==mid)
{
midx=i;
midy=j;
}
if(lenght==len)
{
flag=0;
}
}//////////////循环结束;
t=getendpoint(i,j);
if(t=1&&lenght<minlen)
za=1;////////////表示需要处理了;
else
za=0;/////////表示不需要处理;
for(i=0;i<300;i++)
{
for(j=0;j<300;j++)
{
if(show[i][j]==20)
{
show[i][j]=255;
if(za==1)///////处理了;
data[i][j]=255;
}
}
}
if(za==1)
{
show[a][b]=255;
mart[a][b]=255;
data[a][b]=255;
}
if(lenght>=len)
{
tvx=i-a;
tvy=j-b;
return 1;///表示足够长度了;
}
else
return 0;////////表示不够长度;
}
int CFingerDlg::bijiao(int x, int y)
{
int v;
int a[8],b[8];
int i,j;
int t;
int flag;
int bx[8];
int by[8];
int biaozhi[8];
i=0;
flag=0;
t=0;
a[0]=x+1;
b[0]=y;
a[1]=x-1;
b[1]=y;
a[2]=x;
b[2]=y+1;
a[3]=x;
b[3]=y-1;
a[4]=x-1;
b[4]=y-1;
a[5]=x-1;
b[5]=y+1;
a[6]=x+1;
b[6]=y-1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -