Fit shape to pixel blob



In order to fit a body model og a persons limbs into a binary image, I
am looking for input as to what algorithm would be suitable.

Initially I have a binary image of a persons silhuette as well as the
current body configuration. Next the person moves and the silhuette
changes. Now I need to update the body model to get the best fit where
the recorded silhuette and the body models silhuette will align best.

The problem is how to define "best".
I consider assigning a depth (from edge) value to all pixels -
including negative distance for pixels not in the silhuette - and then
define a best fit based on least error.
An error is the pixels not included in both silhuettes (binary image
and body models calculated silhuette) and its value is the squared
edge distance.

If I see a pixel as included in the silhuette, but the body model's
silhuette does not agree, then it is an error and vice verse.

Does that sound sensible?

If so, then the next question is how to best minimize the parameters
for the body model. It will be a somewhat large number, and I fail to
see how this can be rewritten into an equation which I can minimize
the "easy" way. What is the alternative? Evaluate each parameter
individually and estimate the parameters gradient using finite
difference and then minimize it?
.