Skip to content

Advanced enhancement, local contrast, and edges

Copy page

Enhancement is not a single “make it better” switch. Each variant shows the generated output first, followed by the corresponding binding code.

sigma: 2 reduces high-frequency detail. All four bindings have run; govips is the reference output and the other results still await pixel comparison.

image-enhancement output
WEBP1938 × 1292, 92,650 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

image, err := vips.NewImageFromFile("input.jpg")
if err != nil { return err }
defer image.Close()
if err := image.GaussianBlur(2); err != nil { return err }
data, _, err := image.ExportWebp(vips.NewWebpExportParams())
if err != nil { return err }
return os.WriteFile("blur.webp", data, 0o644)

The example uses sigma: 2 and explicit mask parameters. Sharpening can also amplify noise and compression artefacts.

image-enhancement output
WEBP1938 × 1292, 618,758 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

if err := image.Sharpen(2, 2, 3); err != nil { return err }
data, _, err := image.ExportWebp(vips.NewWebpExportParams())
if err != nil { return err }
return os.WriteFile("sharpen.webp", data, 0o644)

1.5 is this example’s exponent, not a universal default.

image-enhancement output
WEBP1938 × 1292, 490,284 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

if err := image.Gamma(1.5); err != nil { return err }
data, _, err := image.ExportWebp(vips.NewWebpExportParams())
if err != nil { return err }
return os.WriteFile("gamma.webp", data, 0o644)

govips and the CLI use Sobel. sharp executes the same Sobel kernel with convolve(). All three outputs were generated, but convolution borders and encoding differences still need comparison in the target use case.

image-enhancement output
WEBP1938 × 1292, 943,036 bytes, 3 bands

Generated with govips v2.19.0 / libvips 8.17.3.

if err := image.Sobel(); err != nil { return err }
data, _, err := image.ExportWebp(vips.NewWebpExportParams())
if err != nil { return err }
return os.WriteFile("edge.webp", data, 0o644)

sharp also exposes normalise(), clahe(), and arbitrary convolve(). Only the actually executed Sobel convolution has a cross-binding output on this page. normalise() and clahe() have no matching govips v2.19.0 high-level public entry point, so no invented govips implementation is shown. That gap does not mean libvips lacks the operation, and internal vipsGen* functions are not a stable application API.