Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.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 TypeError:不支持*:';JPEG图像文件';和';浮动';_Python_Image Processing - Fatal编程技术网

Python TypeError:不支持*:';JPEG图像文件';和';浮动';

Python TypeError:不支持*:';JPEG图像文件';和';浮动';,python,image-processing,Python,Image Processing,我试着运行这段代码它显示错误- Traceback (most recent call last): File "C:\Python36-32\test1.py", line 13, in <module> img_tinted = img * [1, 0.95, 0.9] TypeError: unsupported operand type(s) for *: 'JpegImageFile' and 'float' 好的,但是你打算代码做什么?消除错误很容易——只需

我试着运行这段代码它显示错误-

Traceback (most recent call last):
  File "C:\Python36-32\test1.py", line 13, in <module>
    img_tinted = img * [1, 0.95, 0.9]
TypeError: unsupported operand type(s) for *: 'JpegImageFile' and 'float'

好的,但是你打算代码做什么?消除错误很容易——只需删除有问题的代码行。修复错误更加困难,如果您不告诉我们有关代码用途的任何信息,则无法完成。请尝试
img[:,:,1]*=0.95
img[:,:,2]*=0.9
。如何
img=(img*np.array([1,0.95,0.9])。astype('uint8')
?您是否阅读过此
imread已弃用!在SciPy 1.0.0中不推荐使用imread,并将在1.2.0中删除。改用imageio.imread。
from?
img\u tinted=img*[1,0.95,0.9]
对我有用。。在您阅读/创建了
type(img)
之后,您会得到什么?
from scipy.misc import imread, imsave, imresize

# Read an JPEG image into a numpy array
img = imread('assets/cat.jpg')
print(img.dtype, img.shape)  # Prints "uint8 (400, 248, 3)"

img_tinted = img * [1, 0.95, 0.9]

# Resize the tinted image to be 300 by 300 pixels.
img_tinted = imresize(img_tinted, (300, 300))

# Write the tinted image back to disk
imsave('assets/cat_tinted.jpg', img_tinted)