我有两个JPEG,并且想要在Photoshop(和Fireworks)中提供与“光度”模式相同的结果。 您可以在此处阅读有关亮度模式的更多信息: http : //www.adobetutorialz.com/articles/662/1/Photoshop%92s-Luminosity-Mode
我怎样才能做到这一点? 编程语言并不重要,但我最熟悉Python和PHP(按此顺序)。 Python Imaging Library看起来非常合适,但是光度不是内置函数,我不知道正确的程序。 请参阅http://effbot.org/imagingbook/imagechops.htm
I have two JPEG's and would like to overlay one on the other with the same results as the "Luminosity" mode available in Photoshop (and Fireworks). You can read more about Luminosity mode here: http://www.adobetutorialz.com/articles/662/1/Photoshop%92s-Luminosity-Mode
How can I do this? Programming language doesn't matter much, but I am most fluent with Python and PHP (in that order). Python Imaging Library seems like a perfect fit, but luminosity is not a built-in function and I do not know the proper procedure. See http://effbot.org/imagingbook/imagechops.htm
最满意答案
我不知道这个特定的过滤器,但我可以告诉你如何遵循PIL中的 Coincoin步骤。 我没有真正运行代码,但可以将其用作参考:
加载源JPEG和目标JPEG
from PIL import Image img1 = Image.open('image1.jpg') img2 = Image.open('image2.jpg')将像素从RGB颜色空间转换为L a b颜色空间(或任何其他具有夜光信息的颜色空间)
# Color matrix for Lab colorMatrix = ( x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0 ) img1 = img1.convert("RGB", colorMatrix) img2 = img2.convert("RGB", colorMatrix)保留目标色彩通道并按照光源的亮度替换其光度通道
l1, a1, b1 = img1.split() l2, a2, b2 = img2.split() img1.putdata(zip(l1.getdata(), a2.getdata(), b2.getdata()))转换回RGB空间
# Color matrix for RGB RGBcolorMatrix = ( x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0 ) img1 = img1.convert("RGB", RGBcolorMatrix)保存JPEG
img1.save('new_image.jpg')I don't know about this specific filter but I can tell you how to follow Coincoin steps in PIL. I didn't actually run the code, but you can use it as a reference:
Load both the source and target JPEGs
from PIL import Image img1 = Image.open('image1.jpg') img2 = Image.open('image2.jpg')Convert the pixels from RGB color space to Lab color space (or any other color space with luminosirty information)
# Color matrix for Lab colorMatrix = ( x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0 ) img1 = img1.convert("RGB", colorMatrix) img2 = img2.convert("RGB", colorMatrix)Preserve target color channels and replace its luminosity channel by source's luminosity
l1, a1, b1 = img1.split() l2, a2, b2 = img2.split() img1.putdata(zip(l1.getdata(), a2.getdata(), b2.getdata()))Convert back to RGB space
# Color matrix for RGB RGBcolorMatrix = ( x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0 ) img1 = img1.convert("RGB", RGBcolorMatrix)Save the JPEG
img1.save('new_image.jpg')更多推荐
发布评论