Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1073161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:57:18+00:00 2026-05-16T20:57:18+00:00

I’m helping a veterinary clinic measuring pressure under a dogs paw. I use Python

  • 0

I’m helping a veterinary clinic measuring pressure under a dogs paw. I use Python for my data analysis and now I’m stuck trying to divide the paws into (anatomical) subregions.

I made a 2D array of each paw, that consists of the maximal values for each sensor that has been loaded by the paw over time. Here’s an example of one paw, where I used Excel to draw the areas I want to ‘detect’. These are 2 by 2 boxes around the sensor with local maxima’s, that together have the largest sum.

alt text

So I tried some experimenting and decide to simply look for the maximums of each column and row (can’t look in one direction due to the shape of the paw). This seems to ‘detect’ the location of the separate toes fairly well, but it also marks neighboring sensors.

alt text

So what would be the best way to tell Python which of these maximums are the ones I want?

Note: The 2×2 squares can’t overlap, since they have to be separate toes!

Also I took 2×2 as a convenience, any more advanced solution is welcome, but I’m simply a human movement scientist, so I’m neither a real programmer or a mathematician, so please keep it ‘simple’.

Here’s a version that can be loaded with np.loadtxt


Results

So I tried @jextee’s solution (see the results below). As you can see, it works very on the front paws, but it works less well for the hind legs.

More specifically, it can’t recognize the small peak that’s the fourth toe. This is obviously inherent to the fact that the loop looks top down towards the lowest value, without taking into account where this is.

Would anyone know how to tweak @jextee’s algorithm, so that it might be able to find the 4th toe too?

alt text

Since I haven’t processed any other trials yet, I can’t supply any other samples. But the data I gave before were the averages of each paw. This file is an array with the maximal data of 9 paws in the order they made contact with the plate.

This image shows how they were spatially spread out over the plate.

alt text

Update:

I have set up a blog for anyone interested and I have setup a OneDrive with all the raw measurements. So to anyone requesting more data: more power to you!


New update:

So after the help I got with my questions regarding paw detection and paw sorting, I was finally able to check the toe detection for every paw! Turns out, it doesn’t work so well in anything but paws sized like the one in my own example. Off course in hindsight, it’s my own fault for choosing the 2×2 so arbitrarily.

Here’s a nice example of where it goes wrong: a nail is being recognized as a toe and the ‘heel’ is so wide, it gets recognized twice!

alt text

The paw is too large, so taking a 2×2 size with no overlap, causes some toes to be detected twice. The other way around, in small dogs it often fails to find a 5th toe, which I suspect is being caused by the 2×2 area being too large.

After trying the current solution on all my measurements I came to the staggering conclusion that for nearly all my small dogs it didn’t find a 5th toe and that in over 50% of the impacts for the large dogs it would find more!

So clearly I need to change it. My own guess was changing the size of the neighborhood to something smaller for small dogs and larger for large dogs. But generate_binary_structure wouldn’t let me change the size of the array.

Anyone has a better suggestion for locating the toes, perhaps having the toe area scale with the paw size?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:57:18+00:00Added an answer on May 16, 2026 at 8:57 pm

    I detected the peaks using a local maximum filter. Here is the result on your first dataset of 4 paws:
    Peaks detection result

    I also ran it on the second dataset of 9 paws and it worked as well.

    Here is how you do it:

    import numpy as np
    from scipy.ndimage.filters import maximum_filter
    from scipy.ndimage.morphology import generate_binary_structure, binary_erosion
    import matplotlib.pyplot as pp
    
    #for some reason I had to reshape. Numpy ignored the shape header.
    paws_data = np.loadtxt("paws.txt").reshape(4,11,14)
    
    #getting a list of images
    paws = [p.squeeze() for p in np.vsplit(paws_data,4)]
    
    
    def detect_peaks(image):
        """
        Takes an image and detect the peaks usingthe local maximum filter.
        Returns a boolean mask of the peaks (i.e. 1 when
        the pixel's value is the neighborhood maximum, 0 otherwise)
        """
    
        # define an 8-connected neighborhood
        neighborhood = generate_binary_structure(2,2)
    
        #apply the local maximum filter; all pixel of maximal value 
        #in their neighborhood are set to 1
        local_max = maximum_filter(image, footprint=neighborhood)==image
        #local_max is a mask that contains the peaks we are 
        #looking for, but also the background.
        #In order to isolate the peaks we must remove the background from the mask.
    
        #we create the mask of the background
        background = (image==0)
    
        #a little technicality: we must erode the background in order to 
        #successfully subtract it form local_max, otherwise a line will 
        #appear along the background border (artifact of the local maximum filter)
        eroded_background = binary_erosion(background, structure=neighborhood, border_value=1)
    
        #we obtain the final mask, containing only peaks, 
        #by removing the background from the local_max mask (xor operation)
        detected_peaks = local_max ^ eroded_background
    
        return detected_peaks
    
    
    #applying the detection and plotting results
    for i, paw in enumerate(paws):
        detected_peaks = detect_peaks(paw)
        pp.subplot(4,2,(2*i+1))
        pp.imshow(paw)
        pp.subplot(4,2,(2*i+2) )
        pp.imshow(detected_peaks)
    
    pp.show()
    

    All you need to do after is use scipy.ndimage.measurements.label on the mask to label all distinct objects. Then you’ll be able to play with them individually.

    Note that the method works well because the background is not noisy. If it were, you would detect a bunch of other unwanted peaks in the background. Another important factor is the size of the neighborhood. You will need to adjust it if the peak size changes (the should remain roughly proportional).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.