JWS C Library
C language utility library
|
Declarations for an image and associated functions. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include "jwsc/base/error.h"
#include "jwsc/matrix/matrix.h"
Go to the source code of this file.
Data Structures | |
struct | Pixel_f |
A 3-sample single precision floating point picture element. More... | |
struct | Image_f |
An image of Pixel_f. More... | |
Typedefs | |
typedef struct Pixel_f | Pixel_f |
A 3-sample single precision floating point picture element. | |
typedef struct Image_f | Image_f |
An image of Pixel_f. | |
Functions | |
create_image | |
Creates an image. | |
void | create_image_f (Image_f **img_out, uint32_t num_rows, uint32_t num_cols) |
Creates a single precision floating point image. | |
create_init_image | |
Creates and initializes an image. | |
void | create_init_image_f (Image_f **img_out, uint32_t num_rows, uint32_t num_cols, Pixel_f val) |
Creates and initializes a single precision floating point image. | |
create_zero_image | |
Creates an image and initializes it with zeros. | |
void | create_zero_image_f (Image_f **img_out, uint32_t num_rows, uint32_t num_cols) |
Creates a single precision floating point image and initializes it with zeros. | |
create_random_image | |
Creates an image and initializes it with random values. | |
void | create_random_image_f (Image_f **img_out, uint32_t num_rows, uint32_t num_cols, Pixel_f min, Pixel_f max) |
Creates a single precision floating point image and initializes it with random values. | |
create_image_from_matrices | |
Creates an image from a three matrices. | |
Error * | create_image_from_matrices_f (Image_f **img_out, const Matrix_f *m_r, const Matrix_f *m_g, const Matrix_f *m_b) |
Creates a single precision floating point image from three matrices. | |
create_image_from_matrix | |
Creates a grayscale image from a matrix. | |
void | create_image_from_matrix_f (Image_f **img_out, const Matrix_f *m) |
Creates a single precision floating point grayscale image from a matrix. | |
create_matrices_from_image | |
Creates three matrices from an image. | |
void | create_matrices_from_image_f (Matrix_f **m_r_out, Matrix_f **m_g_out, Matrix_f **m_b_out, const Image_f *img) |
Creates three single precision floating point matrices from an image. | |
create_matrix_from_image | |
Creates an averaged matrix from an image. | |
void | create_matrix_from_image_f (Matrix_f **m_out, const Image_f *img, float r_weight, float g_weight, float b_weight) |
Creates an averaged single precision floating point matrix from an image. | |
copy_image | |
Copies an image. | |
void | copy_image_f (Image_f **img_out, const Image_f *img_in) |
Copies a single precision floating point image. | |
free_image | |
Frees an image. | |
void | free_image_f (Image_f *img) |
Frees a single precision floatin point image. |
Declarations for an image and associated functions.
The image holds single precision floating point pixel elements.
Although the image is indexed by row and column, the pixels are allocated as a 1D array in row-major order. So iterating over the pixels can be done inside a single loop.
Definition in file image.h.
A 3-sample single precision floating point picture element.
Sample values range [0,1].
void create_image_f | ( | Image_f ** | img_out, |
uint32_t | num_rows, | ||
uint32_t | num_cols | ||
) |
Creates a single precision floating point image.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
num_rows | Number of rows in the image. |
num_cols | Number of columns in the image. |
Creates and initializes a single precision floating point image.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
num_rows | Number of rows in the image. |
num_cols | Number of columns in the image. |
val | Pixel value to initialize all pixels of the image with. |
void create_zero_image_f | ( | Image_f ** | img_out, |
uint32_t | num_rows, | ||
uint32_t | num_cols | ||
) |
Creates a single precision floating point image and initializes it with zeros.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
num_rows | Number of rows in the image. |
num_cols | Number of columns in the image. |
void create_random_image_f | ( | Image_f ** | img_out, |
uint32_t | num_rows, | ||
uint32_t | num_cols, | ||
Pixel_f | min, | ||
Pixel_f | max | ||
) |
Creates a single precision floating point image and initializes it with random values.
Calls rand() to generate the random numbers.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
num_rows | Number of rows in the image. |
num_cols | Number of columns in the image. |
min | Minimum random value. |
max | Maximum random value. |
Error* create_image_from_matrices_f | ( | Image_f ** | img_out, |
const Matrix_f * | m_r, | ||
const Matrix_f * | m_g, | ||
const Matrix_f * | m_b | ||
) |
Creates a single precision floating point image from three matrices.
img_out | Result parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used. |
m_r | Matrix to copy into the red samples of the image. |
m_g | Matrix to copy into the green samples of the image. |
m_b | Matrix to copy into the blue samples of the image. |
void create_matrices_from_image_f | ( | Matrix_f ** | m_r_out, |
Matrix_f ** | m_g_out, | ||
Matrix_f ** | m_b_out, | ||
const Image_f * | img | ||
) |
Creates three single precision floating point matrices from an image.
m_r_out | Result parameter. Red sample matrix. If *m_r_out is NULL, an image is allocated; otherwise its space is re-used. |
m_g_out | Result parameter. Green sample matrix. If *m_g_out is NULL, an image is allocated; otherwise its space is re-used. |
m_b_out | Result parameter. Blue sample matrix. If *m_b_out is NULL, an image is allocated; otherwise its space is re-used. |
img | Image to copy into the matrices. |
void create_matrix_from_image_f | ( | Matrix_f ** | m_out, |
const Image_f * | img, | ||
float | r_weight, | ||
float | g_weight, | ||
float | b_weight | ||
) |
Creates an averaged single precision floating point matrix from an image.
The weights are normalized to sum to one.
The best weights for a human visible grayscale conversion are
r=0.3 g=0.59 b=0.11
m_out | Result parameter. If *m_out is NULL, a matrix is allocated; otherwise its space is re-used. |
img | Image to copy into the matrix. |
r_weight | Weight of the red sample. |
g_weight | Weight of the green sample. |
b_weight | Weight of the blue sample. |