![]() |
The open imaging DSP library
|
Main user API. More...
Functions | |
| 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. | |
| static int | mpix_image_to_buf (struct mpix_image *img, uint8_t *buffer, size_t size) |
| Convert an image and store it into the output buffer. | |
| static int | mpix_image_convert (struct mpix_image *img, uint32_t new_format) |
| Convert an image to a new pixel format. | |
| static int | mpix_image_palette_encode (struct mpix_image *img, uint32_t fourcc) |
| Convert an image to an indexed color format. | |
| static int | mpix_image_palette_decode (struct mpix_image *img) |
| Convert an image from an indexed color format. | |
| static int | mpix_image_set_palette (struct mpix_image *img, struct mpix_palette *palette) |
| Set the palette of every operation currently in the pipeline. | |
| static int | mpix_image_debayer (struct mpix_image *img, uint32_t window_size) |
| Convert an image from a bayer array format to RGB24. | |
| static int | mpix_image_correct_color_matrix (struct mpix_image *img) |
| Apply Color Correction Matrix (CCM) to the image. | |
| static int | mpix_image_correct_white_balance (struct mpix_image *img) |
| Apply White Balance Correction (AWB) to the image. | |
| static int | mpix_image_correct_black_level (struct mpix_image *img) |
| Apply Black Level Correction (BLC) to the image. | |
| static int | mpix_image_correct_gamma (struct mpix_image *img) |
| Apply Gamma Correction (GC) to the image. | |
| static int | mpix_image_qoi_encode (struct mpix_image *img) |
| Encode an image to the QOI compressed image format. | |
| static int | mpix_image_jpeg_encode (struct mpix_image *img) |
| Compressed an image to the JPEG format. | |
| static int | mpix_image_resize_subsample (struct mpix_image *img, uint16_t width, uint16_t height) |
| Resize an image. | |
| static int | mpix_image_crop (struct mpix_image *img, uint16_t x_offset, uint16_t y_offset, uint16_t crop_width, uint16_t crop_height) |
| Crop an image to a smaller region. | |
| static int | mpix_image_sharpen (struct mpix_image *img, uint8_t level) |
| Apply a sharpen operation to an image. | |
| static int | mpix_image_denoise (struct mpix_image *img, uint8_t level) |
| Apply a denoise operation to an image. | |
| static int | mpix_image_edge_detect (struct mpix_image *img, uint8_t level) |
| Apply an edge detection operation to an image. | |
| static int | mpix_image_gaussian_blur (struct mpix_image *img, uint8_t level) |
| Apply a gaussian blur operation to an image. | |
| static void | mpix_image_from_palette (struct mpix_image *img, const struct mpix_palette *palette) |
| Initialize an image from a palette. | |
| static 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) |
| Optimize a color palette after the values from the image. | |
| static void | mpix_image_free (struct mpix_image *img) |
| Free the resources of an image. | |
| static struct mpix_format * | mpix_image_format (struct mpix_image *img) |
| Get the input format of an image, matching the inage input buffer. | |
| static int | mpix_image_sample_random_rgb (struct mpix_image *img, uint8_t rgb[3]) |
| Collect a random RGB pixel from an image. | |
| static void | mpix_image_stats (struct mpix_image *img, struct mpix_stats *stats) |
| Collect statistics from an image. | |
| static int | mpix_image_ctrl_value (struct mpix_image *img, enum mpix_control_id cid, int32_t value) |
| Set a control to a pipeline. | |
| static int | mpix_image_ctrl_array (struct mpix_image *img, enum mpix_control_id cid, int32_t *array, size_t size) |
| Set a control to a pipeline. | |
| static int | mpix_image_read_output (struct mpix_image *img, const uint8_t **buf, size_t *size) |
| Return the output buffer and its size, resetting it to zero. | |
Main user API.
|
inlinestatic |
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>. |
|
inlinestatic |
Apply Black Level Correction (BLC) to the image.
This operation only adds the processing element. To control the correction, use mpix_image_ctrl_value() with MPIX_CID_GAMMA_LEVEL.
| img | Image to correct. |
|
inlinestatic |
Apply Color Correction Matrix (CCM) to the image.
This operation only adds the processing element. To control the correction, use mpix_image_ctrl_value() with MPIX_CID_COLOR_MATRIX.
| img | Image to correct. |
|
inlinestatic |
Apply Gamma Correction (GC) to the image.
This operation only adds the processing element. To control the correction, use mpix_image_ctrl_value() with MPIX_CID_GAMMA_LEVEL.
| img | Image to correct. |
|
inlinestatic |
Apply White Balance Correction (AWB) to the image.
This operation only adds the processing element. To control the correction, use mpix_image_ctrl_value() with MPIX_CID_WHITE_BALANCE.
| img | Image to correct. |
|
inlinestatic |
Crop an image to a smaller region.
An operation is added to crop the image to a specified rectangular region. The crop region must be within the bounds of the original image.
| img | Image to crop. |
| x_offset | X coordinate of the top-left corner of the crop region. |
| y_offset | Y coordinate of the top-left corner of the crop region. |
| crop_width | Width of the crop region in pixels. |
| crop_height | Height of the crop region in pixels. |
|
inlinestatic |
Set a control to a pipeline.
This is to be set after pipeline elements are added, so that their respective controls are added to the image.
| img | Image to apply the control to |
| cid | Control ID to set if present |
| val | Value to set this control to |
|
inlinestatic |
Set a control to a pipeline.
This is to be set after pipeline elements are added, so that their respective controls are added to the image.
| img | Image to apply the control to |
| cid | Control ID to set if present |
| val | Value to set this control to |
|
inlinestatic |
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). |
|
inlinestatic |
Apply a denoise operation to an image.
| img | Image to work on. |
| level | The pixel size of operation |
|
inlinestatic |
Apply an edge detection operation to an image.
| img | Image to work on. |
| level | The pixel size of operation |
|
inlinestatic |
Get the input format of an image, matching the inage input buffer.
| img | The image to inspect. |
|
inlinestatic |
Free the resources of an image.
This frees all intermediate buffers allocated automatically, but not the buffer field of img which is managed by the caller.
| img | Image to free. |
|
inlinestatic |
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. |
|
inlinestatic |
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. |
|
inlinestatic |
Apply a gaussian blur operation to an image.
| img | Image to work on. |
| level | The pixel size of operation |
|
inlinestatic |
Compressed an image to the JPEG format.
| img | Image to convert to JPEG. |
| int mpix_image_optimize_palette | ( | struct mpix_image * | img, |
| struct mpix_palette * | palette, | ||
| uint16_t | num_samples | ||
| ) |
Optimize a color palette after the values from the image.
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 as desired to optimize more.
| 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. |
|
inlinestatic |
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. The palette must be set once per pipeline before running it.
| img | Image to convert. |
|
inlinestatic |
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.
The size in bytes of the colors buffer is (3 << bit_depth).
| img | Image to convert. |
| fourcc | Palette format Four Character Code, starting with PLT and then a digit. |
|
inlinestatic |
Encode an image to the QOI compressed image format.
| img | Image to convert to QOI format. |
|
inlinestatic |
Return the output buffer and its size, resetting it to zero.
This clears the output buffer while preserving all the operations of the pipeline for another round to happen after it.
| img | Image to flush the output. |
| size | Pointer set to the size of the output buffer. |
|
inlinestatic |
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. |
|
inlinestatic |
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. |
|
inlinestatic |
Set the palette of every operation currently in the pipeline.
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 assign a palette to. |
| palette | The color palette in RGB24 pixel format. |
|
inlinestatic |
Apply a sharpen operation to an image.
| img | Image to work on. |
| level | The pixel size of operation |
|
inlinestatic |
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. |
|
inlinestatic |
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. |
|
inlinestatic |
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. |