The open imaging DSP library
Loading...
Searching...
No Matches
How to do kernel processing

Use libmpix to apply blur, sharpen, denoise, edge detect...

Image kernels are operations that work on the entire image tile-by-tile.

A small square of i.e. 3x3 or 5x5 pixels is processed at a time, and this square is shifted by one pixel to the right repeatedly until it processed the full row, then shift one row below to process the next line, and so forth over the entire image.

This tile-by-tile image processing is very similar to how Convolutional Neural Networks (CNN) process images, as "convolution" is a common operation between kernel processing and CNN.

How to perform kernel processing with libmpix

First load a buffer into an image struct, in one of the supported input format. See Supported operations for the list of all supported operations for each kernel.

struct mpix_image img;
struct mpix_format fmt = { .width = 640, .height = 480, .fourcc = MPIX_FMT_RGB24 };
mpix_image_from_buf(&img, buf, sizeof(buf), &fmt);
#define MPIX_FMT_RGB24
Definition formats.h:125
static void mpix_image_from_buf(struct mpix_image *img, const uint8_t *buffer, size_t size, const struct mpix_format *fmt)
Initialize an image from a memory buffer.
Definition image.h:30
Image format description.
Definition types.h:72
uint16_t width
Definition types.h:76
Represent the image currently being processed.
Definition types.h:136

Then, select the type of kernel operation you wish to perform on the image:

Then call the operation on the image. For instance using the denoise kernel:

mpix_image_kernel_convolve_3x3(&img, MPIX_KERNEL_GAUSSIAN_BLUR);
@ MPIX_KERNEL_GAUSSIAN_BLUR
Definition types.h:42