Reputation: 6624
I want to calculate the correlation between two matrices using correlate2d
(code: corr = correlate2d(im, im, fft = True)
).
correlate2d
was part of scipy and is now under stsci_python.
Currently I am loading modules as follows:
import scipy
from scipy import *
import numpy as np
import stsci
from stsci import *
I get the error name 'correlate2d' is not defined
. What modules do I need to load for this?
Upvotes: 2
Views: 1356
Reputation: 388
SciPy has correlate2d in the signal sub-package:
import scipy.signal
followed by:
corr = scipy.signal.correlate2d(matrix1,matrix2)
SciPy sub-packages need to be imported separately; stsci may be the same.
-Aldo
Upvotes: 1
Reputation: 2732
Try this:
from scipy.stsci.convolve import correlate2d
Or, if stsci
is available as a top-level module:
from stsci.convolve import correlate2d
If you are going to do from stsci import *
for other reasons (although that "is frowned upon, since it often causes poorly readable code"), then you can access the function as convolve.correlate2d
without adding any new imports.
Upvotes: 0