Running the Luminosity Filter in Photoshop

I have two JPEGs and would like to overlay one on the other with the same results as the Luminosity mode available in Photoshop (and Fireworks). You can learn more about Luminosity mode: http://www.adobetutorialz.com/articles/662/1/Photoshop%92s-Luminosity-Mode

How can i do this? The programming language does not really matter, but I am best at knowing Python and PHP (in that order). The Python image library looks perfect, but brightness is not a built-in function, and I don't know the correct procedure. See http://effbot.org/imagingbook/imagechops.htm

+3
source share
5 answers

I do not know about this particular filter, but I can tell you how to follow Coincoin's PIL steps . I really did not run the code, but you can use it as a link:

Download both source and destination JPEG

from PIL import Image
img1 = Image.open('image1.jpg')
img2 = Image.open('image2.jpg')

Convert pixels from an RGB color space to a 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)

Save target color channels and replace its brightness channel by source brightness

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 JPEG

img1.save('new_image.jpg')
+1
source

First you need to understand what Photoshop does.

. .

, , :

  • , JPEG
  • RGB Lab ( luminosirty).
  • .
  • RGB
  • JPEG

, , HSL, , .

+5

:

foreach rgb_pixel1, rgb_pixel2 in image1, image2 {
    hsl1 = RgbToHsl(rgb_pixel1);
    hsl2 = RgbToHsl(rgb_pixel2);
    hsl3 = hsl(hsl1.h, hsl1.s, hsl2.l);
    output_rgb = HslToRgb(hsl3);
}

rgb hsl .

+1

Gimp will be another option - it has an interface for scripts and python api - here is an article on brightness and Gimp . Not sure if this is the same effect as you, though.

0
source

You can look in the OpenCV image processing library . It has Python bindings and handles many of these lower-level image management tasks for you, or at least simplifies them.

0
source

Source: https://habr.com/ru/post/1708113/


All Articles