Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:模块';scipy.stats';没有属性';信号噪声';_Python_Python 3.x_Numpy_Scipy_Attributeerror - Fatal编程技术网

Python 属性错误:模块';scipy.stats';没有属性';信号噪声';

Python 属性错误:模块';scipy.stats';没有属性';信号噪声';,python,python-3.x,numpy,scipy,attributeerror,Python,Python 3.x,Numpy,Scipy,Attributeerror,我正在使用scipy signaltonoise函数,下面是代码,但它返回一个错误。我也在github中搜索了这个,但没有找到。你能帮忙吗 import numpy as np import cv2 import math import os import csv from scipy import stats from PIL import Image from skimage.color import rgb2gray from multiprocessing import Pool fr

我正在使用scipy signaltonoise函数,下面是代码,但它返回一个错误。我也在github中搜索了这个,但没有找到。你能帮忙吗

import numpy as np
import cv2
import math
import os
import csv
from scipy import stats 
from PIL import Image
from skimage.color import rgb2gray
from multiprocessing import Pool
from skimage.feature import local_binary_pattern # Local Binary Pattern function
from scipy.stats import itemfreq # To calculate a normalized histogram
import scipy.stats as sp
from skimage.feature import hog
from scipy.ndimage.measurements import label
from scipy import signal as sg




def calc_snr(img):
    snr = stats.signaltonoise(img, axis=None)
    return snr


 snr = calc_snr(img)

scipy.stats.signaltonoise()
在1.0.0中被删除。如果您需要在不降级scipy的情况下使用该函数,您可以看到该函数在github上删除之前的原始代码,并在下面复制:

import numpy as np
def signaltonoise(a, axis=0, ddof=0):
    a = np.asanyarray(a)
    m = a.mean(axis)
    sd = a.std(axis=axis, ddof=ddof)
    return np.where(sd == 0, 0, m/sd)