Conversation
for more information, see https://pre-commit.ci
|
Very cool, thank you! |
|
I've created matheusmpff#1 with some suggestions. |
| image = image.convert("L") | ||
|
|
||
| Kx = [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]] | ||
| Ky = [[1, 2, 1], [0, 0, 0], [-1, -2, -1]] |
There was a problem hiding this comment.
Just want to confirm - you're sure the Ky values are correct? Looking at https://en.wikipedia.org/wiki/Sobel_operator#Formulation, one might expect that Ky should actually be [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
There was a problem hiding this comment.
I had used an inverted kernel for the Sobel operator in the y direction. The right one is the [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]. But I think in the implementation we use the absolute values of gy so I think the results will be the same. It should be great to change for the correct one
Simplified code
627029f to
3394dc8
Compare
| return out | ||
|
|
||
|
|
||
| def neon_effect( |
There was a problem hiding this comment.
Name this just neon? The other two could also be _effect but it doesn't add much.
|
The PR title and description are about neon and sepia functions, but this also introduces a public
Is it intentional to be part of the public API or should it be |
Description:
This PR introduces two new image processing functions to the
PIL.ImageOpsmodule:sepiaApplies a classic sepia tone effect to RGB images.
Converts the image to RGB if necessary.
Computes new pixel values using the standard sepia formula and clamps results to [0, 255].
Preserves the original image size and mode.
Practical use: adds a warm, vintage look to images with minimal processing overhead.
neon_effectApplies a neon/glow effect to an image.
Internally uses a
Sobel edge-detection filter, Gaussian blur, and colorization.Combines the neon layer with the original image using alpha blending.
Supports RGB images and customizable neon color.
Practical use: highlights edges and details in a visually striking, glowing style.
Benefits:
Expands Pillow’s “ready-made” filters with two highly requested effects.
Provides developers with visually appealing filters without third-party dependencies.
Results
Image after sepia effect:

Image after neon-glow effect:

Notes
There are tests for all functions created in this PR covering the main basic behaviors