Pythonnp.梯度错误值太多,无法取消

2024-09-23 22:29:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图为sharpness check计算图像的渐变,但是下面的代码抛出了一个错误,尽管它应该是非常直接的

import os,sys
from PIL import Image
import numpy as np

B = Image.open("C:\\work\\tech\\blur\\blur.jpg")
By, Bx = np.gradient(B)
Bnorm = np.sqrt(Bx**2 + By**2)
Bsharpness = np.average(Bnorm)

print Bsharpness

错误

^{pr2}$

documentation for np.gradient上写着

For two dimensional arrays, the return will be two arrays ordered by axis.

我检查了this question,但它不符合我的要求


Tags: 图像imageimportbycheck错误nptwo