Ask Your Question
1

How to find the center of one palm in the picture

asked 2017-12-19 08:24:49 -0600

sushiqian gravatar image

updated 2017-12-20 04:25:28 -0600

In the below picture, there is on palm, how to find the center point of this palm using OpenCV? It will be very appreciated if anyone can tell me the method.

image description

I want to find the center point of the palm center region, see the below image, I want to find the center of the red circle

image description

when use connectedComponentsWithStats(), I get the centroid point, see the below image, the centroid point(the blue point) is not which I want

image description

edit retag flag offensive close merge delete

Comments

If you want to do it yourself, you could iterate over the image, all the while finding the average location of the white pixels. Or... see LBerger's answer.

sjhalayka gravatar imagesjhalayka ( 2017-12-19 09:30:18 -0600 )edit

Try finding the maximum inscribed circle or have a look at the distance transform.

Der Luftmensch gravatar imageDer Luftmensch ( 2017-12-20 07:18:05 -0600 )edit
1

You can erode the object a few times to get rid of the fingers. Then get the centroid using the connectedComponentsWithStats or the Hu moments.

kbarni gravatar imagekbarni ( 2017-12-20 07:22:23 -0600 )edit

If it's hard to erode, you may use region growth with left-up-right three directions, starting from the white pixel which has the largest y-value, as a result, you'll get the palm and a finger, shaping like a lollipop. Finally, count the horizontal length for each row to eliminate the finger.

moHe gravatar imagemoHe ( 2017-12-21 05:27:51 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
3

answered 2017-12-21 09:19:48 -0600

sushiqian gravatar image

updated 2017-12-21 09:21:32 -0600

I resolved this problem by using distanceTransform()

int palmCenter(string imageFileName) {
Mat srcImg = imread(imageFileName);
if (srcImg.empty()) {
    cout << "Filed to open the image " << imageFileName << endl;
    return -1;
}

Mat binaryImg;
cvtColor(srcImg, binaryImg, COLOR_BGR2GRAY);
threshold(binaryImg, binaryImg, 200, 255, THRESH_BINARY);
Mat distance;
distanceTransform(binaryImg, distance, DIST_L2, 5, CV_32F);

float maxDist = 0;
int x, y;
for (int i = 0; i < distance.rows; i++) {
    for (int j = 0; j < distance.cols; j++) {
        float dist = distance.at<float>(i, j);
        if (maxDist < dist) {
            x = j; y = i;
            maxDist = dist;
        }
    }
}

circle(srcImg, Point(x, y), 3, Scalar(255, 0, 255), 2, 8, 0);
imshow("palmCenter", srcImg);
waitKey(0);
return 0;  }

The result:

image description

edit flag offensive delete link more
2

answered 2017-12-19 08:28:02 -0600

LBerger gravatar image

Use conectedComponentsWithStats and you will get palm centroid

edit flag offensive delete link more

Comments

I used connectedComponentsWithStats() to get the centroid, but, I found it is the center point of the whole palm, which is not what I want. I want to find the center point of the palm center region, which does not include the finger region

sushiqian gravatar imagesushiqian ( 2017-12-20 04:15:56 -0600 )edit

It's a better to ask a new question because centroid was a good answer to your previous question. Use edit button to reverse to your previous questions and ask a new one : there is no problem

LBerger gravatar imageLBerger ( 2017-12-20 04:38:49 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-19 08:24:49 -0600

Seen: 1,557 times

Last updated: Dec 21 '17