4

Given a photograph of a hand, I'm trying to determine the most appropriate method for locating the positions of the palm connecting the fingers. (i.e the location on the palm furthest from the center of the palm, essentially between the fingers.)

I've been thinking about some of the possible ways of coding this, in particular active shape modelling. However, it seems like active shape modelling would be overkill since all I need is to locate those key points, not to track their movement. I was wondering if anybody familiar with feature identification could suggest a more appropriate technique. Thanks.

Kent
  • 115
  • 1
  • 2
  • 10
  • can you post some image examples? This could be easy or very difficult, depending on the scope of what you are trying to do. – so12311 Jun 03 '11 at 01:50
  • I'm unable to post images on stackoverflow yet (still new, so not enough reputation) but an image example would be... http://www.pollsb.com/photos/o/325808-hand_palm.jpg So i'm trying to find those three feature points which occur at the webbing between the fingers. The hand would always be flat and perpendicular to the camera as in this photo. – Kent Jun 03 '11 at 11:30

1 Answers1

5

Here is some sample code in python, using pymorph and mahotas. It should be fairly trivial to recreate with opencv. If possible I would choose a different background, something farther from skin tone would simplify the initial thresholding.

import pymorph as m
import mahotas

def hsv_from_rgb(image):
    image = image/255.0 
    r, g, b = image[:,:,0], image[:,:,1], image[:,:,2]
    m, M = numpy.min(image[:,:,:3], 2), numpy.max(image[:,:,:3], 2)
    d = M - m

    # Chroma and Value
    c = d
    v = M

    # Hue
    h = numpy.select([c ==0, r == M, g == M, b == M], [0, ((g - b) / c) % 6, (2 + ((b - r) / c)), (4 + ((r - g) / c))], default=0) * 60

    # Saturation
    s = numpy.select([c == 0, c != 0], [0, c/v])

    return h, s, v

image = mahotas.imread('hand.jpg')

#downsample for speed
image = image[::10, ::10, :]

h, s, v = hsv_from_rgb(image)

# binary image from hue threshold
b1 = h<35

# close small holes
b2 = m.closerec(b1, m.sedisk(5))

# remove small speckle
b3 = m.openrec(b2, m.sedisk(5))

# locate space between fingers
b4 = m.closeth(b3, m.sedisk(10))

# remove speckle, artifacts from image frame
b5 = m.edgeoff(m.open(b4))

# find intersection of hand outline with 'web' between fingers
b6 = m.gradm(b3)*b5

# reduce intersection curves to single point (assuming roughly symmetric, this is near the center)
b7 = m.thin(m.dilate(b6),m.endpoints('homotopic'))

# overlay marker points on binary image
out = m.overlay(b3, m.dilate(b7, m.sedisk(3)))

mahotas.imsave('output.jpg', out)

enter image description here

so12311
  • 4,179
  • 1
  • 29
  • 37
  • hsv code lifted from here: http://stackoverflow.com/questions/4890373/detecting-thresholds-in-hsv-color-space-from-rgb-using-python-pil – so12311 Jun 03 '11 at 15:25