better ways to get the ridges of distance transform map?

asked 2016-07-01 03:25:59 -0500

gino0717 gravatar image

Hi there, I'm considering use distance transform map to do some finger detection. I drew a hand, distance transformed it and normalized. It's very useful to find the palm center and I drew a circle to label it.

image description

(Fig.1 a hand transformed by distance transform function)

It seems the ridges of the finger and the palm is very clear to my naked eyes and I want to do something to draw the ridge. just like:

image description

(Fig.2 the ridges painted by painter)

I do something like derivative along the X-axis and Y-axis and the code is like:

for(int i=5;i<dist.rows-5;i+=1)
{
    for(int j=5;j<dist.cols-5;j+=1)
    {

        if(dist.at<float>(i,j)>0.1)
        {
            if(dist.at<float>(i,j)>dist.at<float>(i,j-5)&&
                dist.at<float>(i,j)>dist.at<float>(i,j+5))
            {
                circle(thinfinger,Point2f(j,i),5,CV_RGB(255,0,0),-1);
            }

            if(dist.at<float>(i,j)>dist.at<float>(i-5,j)&&
                dist.at<float>(i,j)>dist.at<float>(i+5,j))
            {
                circle(thinfinger,Point2f(j,i),5,CV_RGB(255,0,0),-1);
            }
        }
    }
}


for(int j=5;j<dist.cols-5;j+=1)
{
    for(int i=5;i<dist.rows-5;i+=1)
    {

        if(dist.at<float>(i,j)>0.1)
        {
            if(dist.at<float>(i,j)>dist.at<float>(i,j-5)&&
                dist.at<float>(i,j)>dist.at<float>(i,j+5))
            {
                circle(thinfinger,Point2f(j,i),6,CV_RGB(255,0,0),-1);
            }

            if(dist.at<float>(i,j)>dist.at<float>(i-5,j)&&
                dist.at<float>(i,j)>dist.at<float>(i+5,j))
            {
                circle(thinfinger,Point2f(j,i),6,CV_RGB(255,0,0),-1);
            }
        }
    }


}

the codes find the singularity point and draw it in another mat, the result shows:

image description

(Fig.3 the ridges of distance transform map)

The result seems reasonable but there are always somewhere not connected together,especially in the seams between the finger and the palm. The result could be better if I do the derivative from more different angles, but it would always some gaps there.

I search the forum to find better solutions. One recommanded "Zhang-Suen fast thinning algorithm", but it seems really slow when I want to do realtime tracking. I searched some jounral papers,and some say that path-finding algorithm can connect all together well. But actually I did the path-finding after and found that the path-finding result can be improved by skeletonizing the fingers, so it's strange to do the path-finding before path-finding.

It's any method I can find the well-connected ridges of distance transform map?

edit retag flag offensive close merge delete

Comments

I think you need median axis or skeleton algorithm. About Skeleton you have this post

LBerger gravatar imageLBerger ( 2016-07-01 06:34:38 -0500 )edit

I tried the code, the result is good but really slow.

gino0717 gravatar imagegino0717 ( 2016-07-04 02:14:49 -0500 )edit

may be this one http://www.sciencedirect.com/science/.... bibiography is necessary..

LBerger gravatar imageLBerger ( 2016-07-04 06:58:28 -0500 )edit

this algorithm also work well but not so different to Zhang-Suen or Guo-Hall algorithm, and these algorithms always cost a lot of time unless using some parallel processing technique. I find a old article here talking about using the distance transform map to find the skeleton, http://www.sciencedirect.com/science/... but the figure is not so clear that I cannot estimate whether the result is good or not.

gino0717 gravatar imagegino0717 ( 2016-07-06 04:49:01 -0500 )edit