#include<cv.h>
#include<highgui.h>
#include<cxcore.h>
//定义细化函数
IplImage * cvThin(IplImage *src,IplImage *dst)
{
IplImage *t_img=cvCreateImage(cvGetSize(src),src->depth,1);
t_img=cvCloneImage(src);
int t1=0,t2=0,t3=0;
bool flag=1;
while(flag)
{
flag=0;
for(int i=2;i<t_img->width -2;i++)
{
for(int j=2;j<t_img->height -2 ;j++)
{
int p0=CV_IMAGE_ELEM(t_img,uchar,j,i);
if(CV_IMAGE_ELEM(t_img,uchar,j,i)==0)
continue;
else
{
//取得周围的14个像素点
int p1=(i==0||j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i-1);
int p2=(j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i);
int p3=(i==t_img->width -1||j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i+1);
int p4=(i==t_img->width -1)?0:CV_IMAGE_ELEM(t_img,uchar,j,i+1);
int p5=(i==t_img->width -1||j==t_img->height -1)?0:CV_IMAGE_ELEM(t_img,uchar,j+1,i+1);
int p6=(j==t_img->height -1)?0:CV_IMAGE_ELEM(t_img,uchar,j+1,i);
int p7=(i==0||j==t_img->height -1)?0
#include<highgui.h>
#include<cxcore.h>
//定义细化函数
IplImage * cvThin(IplImage *src,IplImage *dst)
{
IplImage *t_img=cvCreateImage(cvGetSize(src),src->depth,1);
t_img=cvCloneImage(src);
int t1=0,t2=0,t3=0;
bool flag=1;
while(flag)
{
flag=0;
for(int i=2;i<t_img->width -2;i++)
{
for(int j=2;j<t_img->height -2 ;j++)
{
int p0=CV_IMAGE_ELEM(t_img,uchar,j,i);
if(CV_IMAGE_ELEM(t_img,uchar,j,i)==0)
continue;
else
{
//取得周围的14个像素点
int p1=(i==0||j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i-1);
int p2=(j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i);
int p3=(i==t_img->width -1||j==0)?0:CV_IMAGE_ELEM(t_img,uchar,j-1,i+1);
int p4=(i==t_img->width -1)?0:CV_IMAGE_ELEM(t_img,uchar,j,i+1);
int p5=(i==t_img->width -1||j==t_img->height -1)?0:CV_IMAGE_ELEM(t_img,uchar,j+1,i+1);
int p6=(j==t_img->height -1)?0:CV_IMAGE_ELEM(t_img,uchar,j+1,i);
int p7=(i==0||j==t_img->height -1)?0