Skip to main content
 首页 » 编程设计

python之Python 中 correlate2d 的模块

2025年05月04日8EasonJim

我想使用 correlate2d 计算两个矩阵之间的相关性(代码:corr = correlate2d(im, im, fft = True))。

correlate2d 是 scipy 的一部分,现在在 stsci_python 下.

目前我加载模块如下:

import scipy 
from scipy import * 
import numpy as np 
import stsci 
from stsci import * 

我收到错误 name 'correlate2d' is not defined。我需要为此加载哪些模块?

请您参考如下方法:

SciPy 的信号子包中有correlate2d:

import scipy.signal 

其次是:

corr = scipy.signal.correlate2d(matrix1,matrix2) 

SciPy子包需要单独导入; stsci可能是一样的。

-奥尔多