def _validate_inputs(image, markers, mask):
 if (not isinstance(markers, (np.ndarray, list, tuple))):
  markers = regular_seeds(image.shape, markers)
 elif (markers.shape != image.shape):
  raise ValueError(('Markers (shape %s) must have same shape as image (shape %s)' % (markers.ndim, image.ndim)))
 if ((mask is not None) and (mask.shape != image.shape)):
  raise ValueError('mask must have same shape as image')
 if (mask is None):
  mask = np.ones(image.shape, bool)
 return (image.astype(np.float64), markers.astype(np.int32), mask.astype(np.int8))

def _validate_inputs ( image , markers , mask ) : if ( not isinstance ( markers , ( np . ndarray , list , tuple ) ) ) : markers = regular_seeds ( image . shape , markers ) elif ( markers . shape != image . shape ) : raise ValueError ( ( 'Markers (shape %s) must have same shape as image (shape %s)' % ( markers . ndim , image . ndim ) ) ) if ( ( mask is not None ) and ( mask . shape != image . shape ) ) : raise ValueError ( 'mask must have same shape as image' ) if ( mask is None ) : mask = np . ones ( image . shape , bool ) return ( image . astype ( np . float64 ) , markers . astype ( np . int32 ) , mask . astype ( np . int8 ) )
ensure that all inputs to watershed have matching shapes and types .