- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要使用 python wand(用于 python 的 image-magick 绑定(bind))来创建合成图像,但除了简单地将前景图像复制粘贴到背景图像之外,我在弄清楚如何做其他事情时遇到了一些麻烦。我想要的是,假设我有两张图片:
和
都是jpeg,我想去掉猫的白色背景,然后贴在房间上。其他 python 图像模块的答案,如 PIL,也很好,我只需要一些东西来自动化合成过程。提前致谢。
最佳答案
您可以使用 Image.composite()
实现此目的方法:
import urllib2
from wand.image import Image
from wand.display import display
fg_url = 'http://i.stack.imgur.com/Mz9y0.jpg'
bg_url = 'http://i.stack.imgur.com/TAcBA.jpg'
bg = urllib2.urlopen(bg_url)
with Image(file=bg) as bg_img:
fg = urllib2.urlopen(fg_url)
with Image(file=fg) as fg_img:
bg_img.composite(fg_img, left=100, top=100)
fg.close()
display(bg_img)
bg.close()
关于python - 用python wand合成两个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15144483/
组成:一个类可以将其他类的对象作为成员进行引用。这称为合成,有时也称为具有关系。 由Deitel P.J.,Deitel H.M. -Java如何编程第9版。 在本主题中讨论了这种观点: Prefer
好的,最近我开始关注类,继承,接口(interface)以及它们之间如何交互。在此期间,我在各种论坛/博客/视频上发现了对继承的普遍不屑一顾,并且青睐作曲。好吧,酷一些新东西要学习。通过使用this
如果我有这样的选择语句 SELECT t.time, AS ticks, as num FROM MyTable t; 我可以使用第2列中的计算值作为第3列中计算的基础吗?
我正在使用为我的 HTML 文件启用的 Syntastic。由于我有一个非常大的文件,并且启用了“validator w3”检查器,因此在保存文件时 GVIM 或 VIM 变得非常慢 (:w)。 是否
我正在尝试实现预乘 alpha 混合。在这个页面上:What Is Color Blending? ,他们确实解释了标准的 alpha 混合,但没有解释预乘值。 Alpha 混合:(源 × Blend
我正在尝试打开几个无框架的弹出窗口(顶级)。我可以通过以下方式实现这一目标: window.setWindowFlags(Qt.FramelessWindowHint | Qt.Dialog) 但问题
我们通常知道一个类cannot be unloaded来自 ClassLoader,但 lambda 的合成类似乎可以。 证明: public class Play { static Stri
我正在尝试使用 C 中的相位累加器实现带反馈的 FM 合成运算符。在 Tomisawa 的 original patent 中,进入加法器的相位累加器对负索引和正索引进行计数,从 -pi 正弦波相位的
我正在尝试使用 Canvas 在 HTML5 中重新创建翻页类型的动画。动画基于 this page 的想法.但这并不重要。我遇到的问题是使用“source-in”复合操作没有给我预期的结果,我想澄清
我想在顶栏下方添加一个水平分隔线,如下所示: 我使用的是 Material 3,但无法解析分隔线。这是我的依赖项: dependencies { implementation 'androi
我想在顶栏下方添加一个水平分隔线,如下所示: 我使用的是 Material 3,但无法解析分隔线。这是我的依赖项: dependencies { implementation 'androi
使用 Synth LaF,我无法将 JLabel 的前景颜色设置为“禁用”状态。有人成功做到这一点吗?这是 LaF.xml 文件中标签的样式定义。
我需要对 2 个大小不同的图像进行 alpha 混合。我已经设法通过将大小调整为相同大小来将它们组合起来,因此我已经得到了部分逻辑: import cv2 as cv def combine_two_
我有一个 related question几个月前关于通过合成 (HTML5 Canvas) 为 Canvas 着色。当我再次遇到它时,我确实以某种方式理解了它是如何工作的。但我今天的问题是,是否可以
我需要执行 Source In composition在 2 张图片上。 例如这张图片: 和蒙版图像(用黑色透明和黑白测试): 应该产生结果: 我正在尝试使用 ImageSharp 来做到这一点: i
我是 Objective-C 的新手,我想知道是否有一种简单的方法可以将 id 设置为对象实例(具有合成属性),并直接获取/设置这些属性,例如: id myID = myInstance; myID.
我有一个使用 fragment 来更改 View 而不是启动新 Activity 的 Activity 。假设我有 3 个 fragment A、B 和 C。当应用程序启动时,默认 fragment
我是 kotlin 的新手。我发现并尝试在我的 Activity 类中使用合成方法而不是烦人的方法 findViewById,但我发现“如果我们想在 View 上调用合成属性(有用在适配器类中),我们
我正在使用 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)对于文档所说的 alpha 组合(实际上在 Direct3D 文档中也说了同样的事情)。
我正在使用下面的代码来合并两个 UIImage, 不知道是否有更快的方法。 - (UIImage*) combineImage: (UIImage*) aImage { UIGraphicsB
我是一名优秀的程序员,十分优秀!