After my previous question on [finding toes within each paw](https://stackoverflow.com/questions/3684484), I started loading up other measurements to see how it would hold up. Unfortunately, I quickly ran into a problem with one of the preceding steps: recognizing the paws.

You see, my proof of concept basically took the maximal pressure of each sensor over time and would start looking for the sum of each row, until it finds on that != 0.0. Then it does the same for the columns and as soon as it finds more than 2 rows with that are zero again. It stores the minimal and maximal row and column values to some index.

![alt text](https://i.stack.imgur.com/j6eWv.png)

As you can see in the figure, this works quite well in most cases. However, there are a lot of downsides to this approach (other than being very primitive):

* Humans can have 'hollow feet' which means there are several empty rows within the footprint itself. Since I feared this could happen with (large) dogs too, I waited for at least 2 or 3 empty rows before cutting off the paw. 

This creates a problem if another contact made in a different column before it reaches several empty rows, thus expanding the area. I figure I could compare the columns and see if they exceed a certain value, they must be separate paws.
* The problem gets worse when the dog is very small or walks at a higher pace. What happens is that the front paw's toes are still making contact, while the hind paw's toes just start to make contact within the same area as the front paw!

With my simple script, it won't be able to split these two, because it would have to determine which frames of that area belong to which paw, while currently I would only have to look at the maximal values over all frames.

Examples of where it starts going wrong:

![alt text](https://i.stack.imgur.com/kPTj3.png)
![alt text](https://i.stack.imgur.com/xKLOq.png)

**So now I'm looking for a better way of recognizing and separating the paws** (after which I'll get to the problem of deciding which paw it is!).

**Update:**

I've been tinkering to get Joe's (awesome!) answer implemented, but I'm having difficulties extracting the actual paw data from my files.

![alt text](https://i.stack.imgur.com/83Xx5.png)

The coded\_paws shows me all the different paws, when applied to the maximal pressure image (see above). However, the solution goes over each frame (to separate overlapping paws) and sets the four Rectangle attributes, such as coordinates or height/width. 

I can't figure out how to take these attributes and store them in some variable that I can apply to the measurement data. Since I need to know for each paw, what its location is during which frames and couple this to which paw it is (front/hind, left/right).

**So how can I use the Rectangles attributes to extract these values for each paw?**

I have the measurements I used in the question setup in my public Dropbox folder ([example 1](http://dl.dropbox.com/u/5207386/Examples/Normal%20measurement), [example 2](http://dl.dropbox.com/u/5207386/Examples/Grouped%20up%20paws), [example 3](http://dl.dropbox.com/u/5207386/Examples/Overlapping%20paws)). [For anyone interested I also set up a blog](http://flipserd.com/blog) to keep you up to date :-)