Skip to content

Conversation

@matheusmpff
Copy link

Description:

This PR introduces two new image processing functions to the PIL.ImageOps module:

sepia

Applies 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_effect

Applies 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:
sepia

Image after neon-glow effect:
neon

Notes

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

@aclark4life
Copy link
Member

Very cool, thank you!

@radarhere radarhere changed the title Feat neon and sepia filters Neon and sepia filters Dec 14, 2025
@radarhere
Copy link
Member

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]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@radarhere radarhere force-pushed the feat-neon-and-sepia-filters branch from 627029f to 3394dc8 Compare January 2, 2026 04:48
return out


def neon_effect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name this just neon? The other two could also be _effect but it doesn't add much.

@hugovk
Copy link
Member

hugovk commented Jan 2, 2026

The PR title and description are about neon and sepia functions, but this also introduces a public sobel function, but it's described as internal:

Internally uses a Sobel edge-detection filter , Gaussian blur, and colorization.

Is it intentional to be part of the public API or should it be _sobel to keep it internal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants