首页 > 解决方案 > 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)

标签: pythonnumpycv2

解决方案


推荐阅读