Here Joe Kington's find_paws
function is used.
import numpy as np import scipy.ndimage as ndimage import scipy.spatial as spatial import scipy.misc as misc import matplotlib.pyplot as plt import matplotlib.patches as patches class BBox(object): def __init__(self, x1, y1, x2, y2): ''' (x1, y1) is the upper left corner, (x2, y2) is the lower right corner, with (0, 0) being in the upper left corner. ''' if x1 > x2: x1, x2 = x2, x1 if y1 > y2: y1, y2 = y2, y1 self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 def taxicab_diagonal(self): ''' Return the taxicab distance from (x1,y1) to (x2,y2) ''' return self.x2 - self.x1 + self.y2 - self.y1 def overlaps(self, other): ''' Return True iff self and other overlap. ''' return not ((self.x1 > other.x2) or (self.x2 < other.x1) or (self.y1 > other.y2) or (self.y2 < other.y1)) def __eq__(self, other): return (self.x1 == other.x1 and self.y1 == other.y1 and self.x2 == other.x2 and self.y2 == other.y2) def find_paws(data, smooth_radius = 5, threshold = 0.0001):
gives
source share