![]() |
The open imaging DSP library
|
Main user API. More...
Data Structures | |
struct | mpix_image |
Represent the image currently being processed. More... | |
Functions | |
void | mpix_image_from_buf (struct mpix_image *img, const uint8_t *buf, size_t size, uint16_t width, uint16_t height, uint32_t format) |
Initialize an image from a memory buffer. | |
int | mpix_image_to_buf (struct mpix_image *img, uint8_t *buf, size_t size) |
Convert an image and store it into the output buffer. | |
void | mpix_image_free (struct mpix_image *img) |
Free the intermediate buffers of an image. | |
void | mpix_image_stats (struct mpix_image *img, struct mpix_stats *stats) |
Collect statistics from an image. | |
int | mpix_image_sample_random_rgb (struct mpix_image *img, uint8_t rgb[3]) |
Collect a random RGB pixel from an image. | |
int | mpix_image_convert (struct mpix_image *img, uint32_t new_format) |
Convert an image to a new pixel format. | |
int | mpix_image_palettize (struct mpix_image *img, struct mpix_palette *palette) |
Convert an image to an indexed color format. | |
int | mpix_image_depalettize (struct mpix_image *img, struct mpix_palette *palette) |
Convert an image from an indexed color format. | |
void | mpix_image_from_palette (struct mpix_image *img, struct mpix_palette *palette) |
Initialize an image from a palette. | |
int | mpix_image_to_palette (struct mpix_image *img, struct mpix_palette *palette) |
Convert an image and store it into a color palette. | |
int | mpix_image_optimize_palette (struct mpix_image *img, struct mpix_palette *palette, uint16_t num_samples) |
Update the color palette after an input image buffer. | |
int | mpix_image_debayer (struct mpix_image *img, uint32_t window_size) |
Convert an image from a bayer array format to RGB24. | |
int | mpix_image_qoi_encode (struct mpix_image *img) |
Encode an image to the QOI compressed image format. | |
int | mpix_image_jpeg_encode (struct mpix_image *img) |
Encode an image to the JPEG compressed image format. | |
int | mpix_image_resize (struct mpix_image *img, enum mpix_resize_type type, uint16_t width, uint16_t height) |
Resize an image. | |
int | mpix_image_kernel (struct mpix_image *img, uint32_t kernel_type, int kernel_sz) |
Apply a kernel operation on an image. | |
int | mpix_image_correction (struct mpix_image *img, uint32_t type, union mpix_correction_any *corr) |
Apply an Image Signal Processing (ISP) correction operation to an image. | |
void | mpix_image_print_truecolor (struct mpix_image *img) |
Print an image using higher quality TRUECOLOR terminal escape codes. | |
void | mpix_image_print_256color (struct mpix_image *img) |
Print an image using higher speed 256COLOR terminal escape codes. | |
void | mpix_image_print_ops (struct mpix_image *img) |
Print details about an image and its current list of operations. | |
void | mpix_image_hexdump (struct mpix_image *img) |
Print a hexdump of the image to the console for debug purpose. | |
int | mpix_image_append_op (struct mpix_image *img, const struct mpix_base_op *template, size_t op_sz, size_t buf_sz, size_t threshold) |
Add a operation processing step to an image. | |
int | mpix_image_append_uncompressed_op (struct mpix_image *img, const struct mpix_base_op *op, size_t op_sz) |
Add a operation processing step to an image for uncompressed input data. | |
int | mpix_image_process (struct mpix_image *img) |
Perform all the processing added to the. | |
int | mpix_image_error (struct mpix_image *img, int err) |
Set the error code of the image an error on the image. | |
Main user API.
SPDX-License-Identifier: Apache-2.0
int mpix_image_convert | ( | struct mpix_image * | img, |
uint32_t | new_format | ||
) |
Convert an image to a new pixel format.
An operation is added to convert the image to a new pixel format. If the operation to convert the image from the current format to a new format does not exist, then the error flag is set, which can be accessed as img->err
.
In some cases, converting between two formats requires an intermediate conversion to RGB24.
img | Image to convert. |
new_format | A four-character-code (FOURCC) as defined by <zephyr/drivers/video.h> . |
int mpix_image_correction | ( | struct mpix_image * | img, |
uint32_t | type, | ||
union mpix_correction_any * | corr | ||
) |
Apply an Image Signal Processing (ISP) correction operation to an image.
Kernel operations are working on small blocks of typically 3x3 or 5x5 pixels, repeated over the entire image to apply a desired effect on an image.
img | Image to convert. |
type | The type of ISP to apply as defined in mpix/op_correction.h |
corr | The correction level to apply. |
int mpix_image_debayer | ( | struct mpix_image * | img, |
uint32_t | window_size | ||
) |
Convert an image from a bayer array format to RGB24.
An operation is added to convert the image to RGB24 using the specified window size, such as 2x2 or 3x3.
img | Image to convert. |
window_size | The window size for the conversion, usually 2 (faster) or 3 (higher quality). |
int mpix_image_depalettize | ( | struct mpix_image * | img, |
struct mpix_palette * | palette | ||
) |
Convert an image from an indexed color format.
An operation is added to convert the image from an indexed pixel format given the input palette.
If the palette has up to 2 colors, 8 pixels are packed per byte. If the palette has up to 4 colors, 4 pixels are packed per byte. If the palette has up to 16 colors, 2 pixels are packed per byte. If the palette has up to 256 colors, 1 pixels are packed per byte.
img | Image to convert. |
palette | The color palette to use for the conversion. |
void mpix_image_free | ( | struct mpix_image * | img | ) |
Free the intermediate buffers of an image.
This is only required if not calling any export funcitons such as mpix_image_to_buf.
img | Image for which to release resources. Only internal buffers are freed. |
void mpix_image_from_buf | ( | struct mpix_image * | img, |
const uint8_t * | buf, | ||
size_t | size, | ||
uint16_t | width, | ||
uint16_t | height, | ||
uint32_t | format | ||
) |
Initialize an image from a memory buffer.
img | Image to initialize. |
buf | Memory containinig input image data to process. |
size | Total available size in the buffer, can be bigger/smaller than full width x height. |
width | Width of the complete image in pixels. |
height | Height of the complete image in pixels. |
format | Format of data in the buffer as a four-character-code. |
void mpix_image_from_palette | ( | struct mpix_image * | img, |
struct mpix_palette * | palette | ||
) |
Initialize an image from a palette.
This permits to process a color palette as if it was an RGB24 image, which leads to far fewer data to process than the full frame.
img | Image to convert. |
palette | The color palette to use for the conversion. |
void mpix_image_hexdump | ( | struct mpix_image * | img | ) |
Print a hexdump of the image to the console for debug purpose.
img | Image to print. |
int mpix_image_jpeg_encode | ( | struct mpix_image * | img | ) |
Encode an image to the JPEG compressed image format.
img | Image to convert to JPEG format. |
int mpix_image_kernel | ( | struct mpix_image * | img, |
uint32_t | kernel_type, | ||
int | kernel_sz | ||
) |
Apply a kernel operation on an image.
Kernel operations are working on small blocks of typically 3x3 or 5x5 pixels, repeated over the entire image to apply a desired effect on an image.
img | Image to convert. |
kernel_type | The type of kernel to apply as defined in mpix/op_kernel.h |
kernel_sz | The size of the kernel operaiton, usually 3 or 5. |
int mpix_image_optimize_palette | ( | struct mpix_image * | img, |
struct mpix_palette * | palette, | ||
uint16_t | num_samples | ||
) |
Update the color palette after an input image buffer.
This is performed on the original input image rather than the current state of the image. The strategy used is the "naive k-mean", and only a single pass. Repeat the function several times to improve accuracy.
img | Input image sampled to generate the palette. |
palette | The palette that will be updated with colors fitting the image better. |
num_samples | Number of samples to take from the input image. |
int mpix_image_palettize | ( | struct mpix_image * | img, |
struct mpix_palette * | palette | ||
) |
Convert an image to an indexed color format.
An operation is added to convert the image to an indexed pixel format given the input palette.
If the palette has up to 2 colors, 8 pixels are packed per byte. If the palette has up to 4 colors, 4 pixels are packed per byte. If the palette has up to 16 colors, 2 pixels are packed per byte. If the palette has up to 256 colors, 1 pixels are packed per byte.
img | Image to convert. |
palette | The color palette to use for the conversion. |
void mpix_image_print_256color | ( | struct mpix_image * | img | ) |
Print an image using higher speed 256COLOR terminal escape codes.
img | Image to print. |
void mpix_image_print_ops | ( | struct mpix_image * | img | ) |
Print details about an image and its current list of operations.
img | Image to detail. |
void mpix_image_print_truecolor | ( | struct mpix_image * | img | ) |
Print an image using higher quality TRUECOLOR terminal escape codes.
img | Image to print. |
int mpix_image_qoi_encode | ( | struct mpix_image * | img | ) |
Encode an image to the QOI compressed image format.
img | Image to convert to QOI format. |
int mpix_image_resize | ( | struct mpix_image * | img, |
enum mpix_resize_type | type, | ||
uint16_t | width, | ||
uint16_t | height | ||
) |
Resize an image.
An operation is added to change the image size. The aspect ratio is not preserved and the output image size is exactly the same as requested.
img | Image to convert. |
type | Type of image resizing to apply. |
width | The new width in pixels. |
height | The new height in pixels. |
int mpix_image_sample_random_rgb | ( | struct mpix_image * | img, |
uint8_t | rgb[3] | ||
) |
Collect a random RGB pixel from an image.
The image can have any format from this list:
img | Image to sample a value from. |
rgb | Buffer to 3 bytes filled with the red, green, blue value from the image. |
void mpix_image_stats | ( | struct mpix_image * | img, |
struct mpix_stats * | stats | ||
) |
Collect statistics from an image.
The image buffer is used to collect statistics into a stats
structure.
If the stats
field nval
is non-zero, this number of pixels will be collected randomly from the image to generate statistics such as histogram and .
img | Image to convert. |
stats | Statistics filled from the image. |
int mpix_image_to_buf | ( | struct mpix_image * | img, |
uint8_t * | buf, | ||
size_t | size | ||
) |
Convert an image and store it into the output buffer.
img | Image being processed. |
buf | Memory that receives the image data. |
size | Size of the buffer. |
int mpix_image_to_palette | ( | struct mpix_image * | img, |
struct mpix_palette * | palette | ||
) |
Convert an image and store it into a color palette.
This is the reciproqual operation from mpix_image_from_palette.
img | Image being processed. |
palette | The color palette to use for the conversion. |