Python中文
首页
教程
问答
标签
搜索
登录
注册
在Python(JES)中水平翻转图像
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我需要做一个功能,将复制一个图像,但镜像。我创建了镜像代码,但它不起作用,我不知道为什么,因为我跟踪了代码,它应该镜像图像。代码如下:</p> <pre><code>def invert(picture): width = getWidth(picture) height = getHeight(picture) for y in range(0, height): for x in range(0, width): sourcePixel = getPixel(picture, x, y) targetPixel = getPixel(picture, width - x - 1, height - y - 1) color = getColor(sourcePixel) setColor(sourcePixel, getColor(targetPixel)) setColor(targetPixel, color) show(picture) return picture def main(): file = pickAFile() picture = makePicture(file) newPicture = invert(picture) show(newPicture) </code></pre> <p>有人能告诉我怎么了吗?谢谢您。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>问题是你在整个图像中循环,而不是只有一半的宽度。镜像两次图像,得到与输入图像相同的输出图像。</p> <p>如果你在Y轴上镜像,代码应该是</p> <pre><code>for y in range(0, height): for x in range(0, int(width / 2)): </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
VirtualEnvRapper错误:路径python2(来自python=python2)不存在
6 回答
virtualenvs上的pyinstaller,没有名为导入错误的模块
8 回答
virtualenvs是否可以退回到用户包而不是系统包?
4 回答
virtualenvwrapper CentOS7
2 回答
virtualenvwrapper IOError:[Errno 13]权限被拒绝
5 回答
virtualenvwrapper mkproject和shell在windows中的启动问题?
6 回答
virtualenvwrapper mkvirtualenv不工作但没有错误
1 回答
Virtualenvwrapper python bash
6 回答
virtualenvwrapper:“workon”何时更改到项目目录?
2 回答
virtualenvwrapper:mkvirtualenv可以工作,但是rmvirtualenv返回bash:没有这样的文件或目录
8 回答
virtualenvwrapper:virtualenv信息存储在哪里?
2 回答
virtualenvwrapper:命令“python设置.pyegg_info“失败,错误代码为1
3 回答
virtualenvwrapper:如何将mkvirtualenv的默认Python版本/路径更改为ins
8 回答
Virtualenvwrapper:模块“pkg_resources”没有属性“iter_entry_points”
8 回答
Virtualenvwrapper:没有名为virtualenvwrapp的模块
2 回答
Virtualenvwrapper.bash_profi的正确设置
9 回答
Virtualenvwrapper.hook:权限被拒绝
10 回答
virtualenvwrapper.sh:fork:资源暂时不可用Python/Djang
1 回答
Virtualenvwrapper.shlssitepackages命令不工作
3 回答
Virtualenvwrapper.sh函数在bash sh中不可用
2 回答