python - 如何选择图像的一部分,然后使用 JES 将图像的选定部分以棋盘图案粘贴到另一个图像中?
问题描述
我正在使用Jython
、 或JES
,并且我想以棋盘格图案重复将一个图像的一部分复制到另一个图像中。我想知道如何做到这一点?
到目前为止,我有这个:
def checkerboard(pic):
p = makeEmptyPicture(500,500)
targetX = 100
for sourceX in range(81,123):
targetY = 100
for sourceY in range(99,126):
color = getColor(getPixel(pic,sourceX,sourceY))
setColor(getPixel(p,targetX,targetY),color)
targetY = targetY + 1
targetX = targetX + 1
show(p)
Pic
是用户选择的图像, 和picX
是picY
图片的范围。问题是这只是将图像的一部分粘贴到空图片(p
)中。我希望将图像的一部分重复粘贴到空图片的某个区域中的空图片中。
解决方案
推荐阅读
- c - 如何在 C 中的矩阵(二维数组)内声明双精度数?
- javascript - 如何从描述性对象动态生成类?
- function - Racket 中的“过程”和“功能”是同义词吗?
- git - 是否`
/ 这个 `git checkout` 命令中的` 代表远程分支还是远程跟踪分支? - python - What is the Keras 2.0 equivalent of `similarity = keras.layers.merge([target, context], mode='cos', dot_axes=0)`
- tensorflow - TensorFlow 损失的初始跳跃
- javascript - 如何创建精灵图像按钮并将其添加到 3D 画布?
- input - textarea 的多行插件
- kubernetes - 与依赖提供者一起改造
- linux - 描述 xmm 寄存器中未传递给 rax 的浮点参数数量的整数