GO-IMG-KERNEL is a Go library for image processing, leveraging convolutional operations to perform various transformations such as blurring, edge detection, binarization, and more.
This library aims to provide simple-to-use functions for handling images, whether in RGB or grayscale formats.
- Image loading and saving in various formats (JPEG, PNG).
- Support for RGB and grayscale images.
- Common image transformations:
- Gaussian blur
- Edge detection
- Binarization
- Image rotation and reflection
- Horizontal transformation
- Sharpening
go get github.com/salamnocap/go-img-kernel
go test -v ./test
import (
"github.com/salamnocap/go-img-kernel/utils"
"github.com/salamnocap/go-img-kernel/transformation"
)
rgbImage, err := utils.LoadRGBImage(
"../examples/input/castle_rgb.jpg",
) // Load RGB image
if err != nil {
panic(err)
}
newImage := transformation.BoxBlurRGB(rgbImage, 0, 3) // Apply box blur (0 - padding, 3 -stride)
err = utils.SaveImage(
newImage,
"../examples/output/blurred.jpg",
false,
) // Save image
if err != nil {
panic(err)
}
import (
"github.com/salamnocap/go-img-kernel/kernel"
"github.com/salamnocap/go-img-kernel/utils"
)
// Custom kernel
customKernel := kernel.NewKernel(
3, // Kernel size
[][]float64{
{0, -1, 0},
{-1, 4, -1},
{0, -1, 0},
},
)
inputImage, err := utils.LoadRGBImage(
"../examples/input/castle_rgb.jpg",
) // Load RGB image
if err != nil {
panic(err)
}
outputImage := kernel.Convolve3D(inputImage, customKernel, 0, 1) // Apply custom kernel (0 - padding, 1 - stride)
err = utils.SaveImage(
newImage,
"../examples/output/new_image.jpg",
false, // if false, save as RGB image
) // Save image
if err != nil {
panic(err)
}