gegl:sharpen
My work involved porting a legacy, foundational 3x3 Sharpen matrix over to GIMP's modern core engine, GEGL (Generic Graphics Library).
Gimp's older sharpen filter was removed from GIMP 3.0 due to it not being maintained and only working on 8 bit images and it often operated in a restrictive
environment. It took an image, looked at a tiny grid of pixels, applied some fast math, and spitted out the result. While this worked fine years
ago, it has a massive drawback for modern creators which is that it
destroys data. Legacy filters usually force images into 8-bit precision
(only 256 levels of color per channel) and bake the changes permanently
into your pixels. If you sharpen an image and change your mind later,
you're out of luck.
By rebuilding this Sharpen filter as a native GEGL operation, we are
giving a classic tool a massive performance and fidelity upgrade. The
new implementation focuses on two main pillars which are High Bit-Depth
(Instead of squeezing colors into a 8-bit precision box, the new filter
processes images at 32-bit floating-point precision. This means
absolutely zero color degradation), and Non-Destructive Editing (because
GEGL views image processing as a continuous pipeline (a graph), this
sharpening can happen live. You can tweak, toggle, or adjust the
intensity at any point in your workflow without ever altering your
original source pixels).
For the working part, it was quite straight forward: Imagine a tiny 3x3 grid of pixels sliding across your image. For every
single pixel, the filter looks at its immediate 8 neighbors (surrounding
pixels in the grid), calculates the contrast between them, and
amplifies the difference. By boosting the contrast (amplifying lights
and darks) your eyes perceive the image as significantly sharper. Also the legacy 8-bit filter used integer scaling factors (like
multiplying by 800) and rounding biases (like +4). The goal of my
derivation was to strip away the integer scaling and find the effective
fractional weights applied to the center pixel and its 8 neighbors.
As https://gitlab.gnome.org/GNOME/gegl/-/merge_requests/269 has been merged, you can expect this new Sharpen filter in the upcoming GIMP and GEGL release.
Comments
Post a Comment