def involvedpairs(pairs):
 for pair in pairs:
  (yield pair)
  left = (pair[0], (pair[1] - 1))
  if ((left[1] >= 0) and (left not in pairs)):
   (yield left)
  top = ((pair[0] - 1), pair[1])
  topright = ((pair[0] - 1), (pair[1] + 1))
  if ((pair[0] > 0) and (top not in pairs) and (topright not in pairs)):
   (yield top)

def involvedpairs ( pairs ) : for pair in pairs : ( yield pair ) left = ( pair [ 0 ] , ( pair [ 1 ] - 1 ) ) if ( ( left [ 1 ] >= 0 ) and ( left not in pairs ) ) : ( yield left ) top = ( ( pair [ 0 ] - 1 ) , pair [ 1 ] ) topright = ( ( pair [ 0 ] - 1 ) , ( pair [ 1 ] + 1 ) ) if ( ( pair [ 0 ] > 0 ) and ( top not in pairs ) and ( topright not in pairs ) ) : ( yield top )
get all the pixel pairs whose gradient involves an unknown pixel .