def correlate2d(in1, in2, mode='full', boundary='fill', fillvalue=0):
 in1 = asarray(in1)
 in2 = asarray(in2)
 if (not (in1.ndim == in2.ndim == 2)):
  raise ValueError('correlate2d inputs must both be 2D arrays')
 swapped_inputs = _inputs_swap_needed(mode, in1.shape, in2.shape)
 if swapped_inputs:
  (in1, in2) = (in2, in1)
 val = _valfrommode(mode)
 bval = _bvalfromboundary(boundary)
 with warnings.catch_warnings():
  warnings.simplefilter('ignore', np.ComplexWarning)
  out = sigtools._convolve2d(in1, in2, 0, val, bval, fillvalue)
 if swapped_inputs:
  out = out[::(-1), ::(-1)]
 return out

def correlate2d ( in1 , in2 , mode = 'full' , boundary = 'fill' , fillvalue = 0 ) : in1 = asarray ( in1 ) in2 = asarray ( in2 ) if ( not ( in1 . ndim == in2 . ndim == 2 ) ) : raise ValueError ( 'correlate2d inputs must both be 2D arrays' ) swapped_inputs = _inputs_swap_needed ( mode , in1 . shape , in2 . shape ) if swapped_inputs : ( in1 , in2 ) = ( in2 , in1 ) val = _valfrommode ( mode ) bval = _bvalfromboundary ( boundary ) with warnings . catch_warnings ( ) : warnings . simplefilter ( 'ignore' , np . ComplexWarning ) out = sigtools . _convolve2d ( in1 , in2 , 0 , val , bval , fillvalue ) if swapped_inputs : out = out [ : : ( - 1 ) , : : ( - 1 ) ] return out
cross-correlate two 2-dimensional arrays .