Use libmpix to collect pixel values from the image.
libmpix supports collecting individual pixels from the image in RGB value without having to convnert the entire image. Each pixel sampled will be individually converted.
How to sample pixels from the image with libmpix
First load a buffer into an image struct, specifying the pixel format:
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
Represent the image currently being processed.
Definition types.h:136
Then collect an individual pixel from the image.
For now only sampling from a random location is supported.
uint8_t rgb_value[3];
static int mpix_image_sample_random_rgb(struct mpix_image *img, uint8_t rgb[3])
Collect a random RGB pixel from an image.
Definition image.h:408
- Note
- Statistics collection must be done before any other operation.
Future development
This API is still unstable, as in the future, more advanced pixel collection is planned:
- Sampling data from arbitrary coordinates.
- Batch collection of data by appending them into a buffer, permitting to process them as regular mpix_image.
- More strategies for selecting random pixels within a region of the image, collect an entire NxN tile at given coordinate.
- Collecting a grid of equally spaced pixels leveraging MPIX_RESIZE_SUBSAMPLING as back-end.
Something else? Then let us know what you needed.