JWS C Library
C language utility library
image_util.h File Reference

Declarations for image utility functions. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include "jwsc/base/error.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/image/image.h"
Include dependency graph for image_util.h:

Go to the source code of this file.

Functions

down_sample_image

Down samples an image.

Errordown_sample_image_f (Image_f **img_out, const Image_f *img_in, float row_factor, float col_factor)
 Down samples a single precision image.
extend_image

Extends an image into a padding region.

void extend_image_f (Image_f **img_out, const Image_f *img_in, uint32_t row_padding, uint32_t col_padding)
 Extends a single precision image into a padding region.
crop_image

Crops an image.

Errorcrop_image_f (Image_f **img_out, const Image_f *img_in, uint32_t row, uint32_t col, uint32_t num_rows, uint32_t num_cols)
 Crops a single precision image into a padding region.
threshold_image

Thresholds a image.

void threshold_image_f (Matrix_f **mat_out, const Image_f *img_in, float t)
 Thresholds a single precision image.
threshold_matrix

Thresholds a matrix.

void threshold_matrix_f (Matrix_f **mat_out, const Matrix_f *mat_in, float t)
 Thresholds a single precision matrix.
dynamically_threshold_image

Dynamically thresholds an image.

void dynamically_threshold_image_f (Matrix_f **mat_out, const Image_f *img_in)
 Dynamically thresholds a single precision image.
dynamically_threshold_matrix

Dynamically thresholds a matrix.

void dynamically_threshold_matrix_f (Matrix_f **mat_out, const Matrix_f *mat_in)
 Dynamically thresholds a single precision matrix.

Detailed Description

Declarations for image utility functions.

Author:
Joseph Schlecht
License:
Creative Commons BY-NC-SA 3.0

Definition in file image_util.h.


Function Documentation

Error* down_sample_image_f ( Image_f **  img_out,
const Image_f img_in,
float  row_factor,
float  col_factor 
)

Down samples a single precision image.

Uses a Gaussian smoothing function to down sample.

Parameters:
img_outResult parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used.
img_inImage to down sample.
row_factorPercentage of current number of rows to down sample the number of rows in the image to, in the range (0,1].
col_factorPercentage of current number of columns to down sample the number of columns in the image to, in the range (0,1].
Returns:
On success, NULL is returned. On error, an Error is returned and *img_out is freed and set to NULL (if it is not img_in).
  • ERROR_INV_ARG Down sampling row_factor or col_factor are not in (0, 1].
Note:
If *img_out == img_in, then img_in is overwritten.

Definition at line 87 of file image_util.c.

void extend_image_f ( Image_f **  img_out,
const Image_f img_in,
uint32_t  row_padding,
uint32_t  col_padding 
)

Extends a single precision image into a padding region.

Parameters:
img_outResult parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used.
img_inImage to extend.
row_paddingNumber or rows for padding on top and bottom.
col_paddingNumber of columns for padding on left and right.
Note:
If *img_out == img_in, then img_in is overwritten.

Definition at line 273 of file image_util.c.

Error* crop_image_f ( Image_f **  img_out,
const Image_f img_in,
uint32_t  row,
uint32_t  col,
uint32_t  num_rows,
uint32_t  num_cols 
)

Crops a single precision image into a padding region.

Parameters:
img_outResult parameter. If *img_out is NULL, an image is allocated; otherwise its space is re-used.
img_inImage to crop.
rowFirst row to use in the cropped result.
colFirst col to use in the cropped result.
num_rowsNumber of rows to use in the cropped result.
num_colsNumber of cols to use in the cropped result.
Returns:
On success, NULL is returned. On error, an Error is returned and *img_out is freed and set to NULL (if it is not img_in).

Definition at line 361 of file image_util.c.

void threshold_image_f ( Matrix_f **  mat_out,
const Image_f img_in,
float  t 
)

Thresholds a single precision image.

The image is converted to grayscale and thresholded with t as follows

    m[i,j] <  t : m[i,j] = 0
    m[i,j] >= t : m[i,j] = 1

Definition at line 438 of file image_util.c.

void threshold_matrix_f ( Matrix_f **  mat_out,
const Matrix_f mat_in,
float  t 
)

Thresholds a single precision matrix.

The matrix is thresholded with t as follows

    m[i,j] <  t : m[i,j] = 0
    m[i,j] >= t : m[i,j] = 1

Definition at line 469 of file image_util.c.

void dynamically_threshold_image_f ( Matrix_f **  mat_out,
const Image_f img_in 
)

Dynamically thresholds a single precision image.

A threshold t is iteratively found as the average between the mean foreground and background values.

The image is converted to grayscale and thresholded with t as follows

    m[i,j] <  t : m[i,j] = 0
    m[i,j] >= t : m[i,j] = 1

Definition at line 523 of file image_util.c.

void dynamically_threshold_matrix_f ( Matrix_f **  mat_out,
const Matrix_f mat_in 
)

Dynamically thresholds a single precision matrix.

A threshold t is iteratively found as the average between the mean foreground and background values.

The matrix is thresholded with t as follows

    m[i,j] <  t : m[i,j] = 0
    m[i,j] >= t : m[i,j] = 1

Definition at line 556 of file image_util.c.