python打开文件报错OSError: [Errno 22] Invalid argument:
2017-10-25 09:29
986 查看
1)从电脑属性复制的文件地址为:E:\python_code\beijing.jpg
2)操作步骤:将盘符’E’修改为‘e’;将转义字符’\’修改为’/’,即可运行通过。(大部分情况不需要进行此操作,大小写无所谓)
代码块如下:
2)操作步骤:将盘符’E’修改为‘e’;将转义字符’\’修改为’/’,即可运行通过。(大部分情况不需要进行此操作,大小写无所谓)
代码块如下:
from PIL import Image import numpy as np a = np.asarray(Image.open('e:/python_code/beijing.jpg').convert('L')).astype('float') depth = 10. # (0-100) grad = np.gradient(a) #取图像灰度的梯度值 grad_x, grad_y = grad #分别取横纵图像梯度值 grad_x = grad_x*depth/100. grad_y = grad_y*depth/100. A = np.sqrt(grad_x**2 + grad_y**2 + 1.) uni_x = grad_x/A uni_y = grad_y/A uni_z = 1./A vec_el = np.pi/2.2 # 光源的俯视角度,弧度值 vec_az = np.pi/4. # 光源的方位角度,弧度值 dx = np.cos(vec_el)*np.cos(vec_az) # 光源对x 轴的影响 dy = np.cos(vec_el)*np.sin(vec_az) # 光源对y 轴的影响 dz = np.sin(vec_el) # 光源对z 轴的影响 b = 255*(dx*uni_x + dy*uni_y + dz*uni_z) # 光源归一化 b = b.clip(0, 255) im = Image.fromarray(b.astype('uint8')) # 重构图像 im.save('e:/python_code/beijing1.jpg')
相关文章推荐
- 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’
- python open() 打开文件出现 IOError: [Errno 22] invalid mode ('r') or filename:
- Python打开文件出现IOError: [Errno 22] invalid mode ('rb') or filename
- windows下运行python爬虫脚本乱码问题,IOError: [Errno 22] Invalid argument
- Python3.0中的OSError: [Errno 22] Invalid argument:..........
- ipv6环境下python报[Errno 22] Invalid argument
- pefile under python 2.4 (centos os ) EnvironmentError: [Errno 22] Invalid argument
- python中用open打开文件,报错 IOError:[Error 22] invalid mode ('rb') or filename
- 【Python】按行读取文件、IOError: [Errno 22] invalid mode ('a+') or filename,处理文件的换行符
- Python在写入文件时中文报错IOError: [Errno 22] invalid mode ('w') or filename
- 错误代码: 1017 Can't find file: '.\bus\t_driver_info@ff1b.frm' (errno: 22 - Invalid argument)
- python读取文件报错OSError: [Errno 22] Invalid argument: '\u202aC:\\Users\\yyqhk\\Desktop\\1.csv'
- sendto 返回-1,errno为22,invalid argument的解决办法,mark一下
- 读取数据报错:[Errno 22] Invalid argument
- setsockopt invalid argument,errno 22
- python做工具遇到报错:[Errno 22] invalid mode ('rb') or filename
- Python报错IOError: [Errno 22] invalid mode ('r') or filename
- python IOError: [Errno 22] invalid mode ('r') or filename:
- OSError: [Errno 22] Invalid argument:
- Python:[转]IOError: [Errno 22] invalid mode ('r') or filename: