python - python错误:TypeError:+的不支持的操作数类型:'NoneType'和'int'。如何解决这个问题?
问题描述
我编写代码来转换一些图像,但是发生了这个错误。错误在这一行
new_img = np.add(nul_img, np.array([beta]))
错误说明了这一点
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
我试图在我朋友的计算机上运行代码并且它有效,但在我的计算机上却没有
这是代码
import numpy as np
import cv2
alpha = float(input('Enter The alpha value [1.0-3.0]'))
beta = int(input('Enter the beta value [0-100]:' ))
img = cv2.imread('spider.jpg')
nul_img = cv2.multiply(img, np.array([alpha]))
new_img = np.add(nul_img, np.array([beta]))
new_img = np.uint8(new_img)
解决方案
推荐阅读
- python - 在 Python 中基于外部生成的表(即 csv 文件或数据框)动态选择数据框的元素
- rxjs - 如何更新 BehaviorSubject 中 1 个对象中的 1 个属性并让所有观察者知道
- javascript - 如何使用 useContext 更改 Context 的值?
- python - 从熊猫数据框中的行子集中计算平均值:groupby 还是 for 循环?
- c# - 将 Deedle 数据框转换为自定义类的 C# 列表
- python - 在没有结果的情况下用 Python 计算曼哈顿距离
- android - 对象实现 Parcelable 时未找到类异常
- docker - Golang Docker 容器未在 Docker-Compose 中重新启动
- .net - 在以下主要来源中找不到包
- arrays - Ruby数组合并方法