JWS C Library
C language utility library
2d.c File Reference

Definitions for matrix filters. More...

#include <jwsc/config.h>
#include <stdlib.h>
#include <inttypes.h>
#include <math.h>
#include <assert.h>
#include "jwsc/base/error.h"
#include "jwsc/prob/pdf.h"
#include "jwsc/matrix/matrix.h"
#include "jwsc/matrix/matrix_math.h"
#include "jwsc/filter/2d.h"
Include dependency graph for 2d.c:

Go to the source code of this file.

Defines

#define PI   3.14159265358979323846
 Estimate of pi.

Functions

create_sobel_x_filter

Creates a Sobel operator for the x direction.

void create_sobel_x_filter_f (Matrix_f **sobel_out)
 Creates a single precision Sobel operator for the x direction.
void create_sobel_x_filter_d (Matrix_d **sobel_out)
 Creates a double precision Sobel operator for the x direction.
create_sobel_y_filter

Creates a Sobel operator for the y direction.

void create_sobel_y_filter_f (Matrix_f **sobel_out)
 Creates a single precision Sobel operator for the y direction.
void create_sobel_y_filter_d (Matrix_d **sobel_out)
 Creates a double precision Sobel operator for the y direction.
create_LoG_filter

Creates a Laplacian of Gaussian filter.

Errorcreate_LoG_filter_f (Matrix_f **LoG_out, float sigma)
 Creates a single precision Laplacian of Gaussian filter.
create_auto_2d_gaussian_filter

Creates a 2D Gaussian filter automatically sized to sqrt(2)*6*sigma.

Errorcreate_auto_2d_gaussian_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma)
 Creates a single precision 2D Gaussian filter automatically sized.
Errorcreate_auto_2d_gaussian_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma)
 Creates a double precision 2D Gaussian filter automatically sized.
create_2d_gaussian_filter

Creates a 2D Gaussian filter.

Errorcreate_2d_gaussian_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a single precision 2D Gaussian filter.
Errorcreate_2d_gaussian_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a double precision 2D Gaussian filter.
create_auto_2d_gaussian_dx_filter

Creates a 2D Gaussian filter with a partial derivative along columns automatically sized to sqrt(2)*6*sigma.

Errorcreate_auto_2d_gaussian_dx_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma)
 Creates a single precision 2D Gaussian filter with a partial derivative in the x-direction (column) automatically sized.
Errorcreate_auto_2d_gaussian_dx_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma)
 Creates a double precision 2D Gaussian filter with a partial derivative in the x-direction (column) automatically sized.
create_2d_gaussian_dx_filter

Creates a 2D Gaussian filter with a partial derivative along columns.

Errorcreate_2d_gaussian_dx_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a single precision 2D Gaussian filter with a partial derivative in the x-direction (column).
Errorcreate_2d_gaussian_dx_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a double precision 2D Gaussian filter with a partial derivative in the x-direction (column).
create_auto_2d_gaussian_dy_filter

Creates a 2D Gaussian filter with a partial derivative along rows automatically sized to sqrt(2)*6*sigma.

Errorcreate_auto_2d_gaussian_dy_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma)
 Creates a single precision 2D Gaussian filter with a partial derivative in the y-direction (row) automatically sized.
Errorcreate_auto_2d_gaussian_dy_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma)
 Creates a double precision 2D Gaussian filter with a partial derivative in the y-direction (row) automatically sized.
create_2d_gaussian_dy_filter

Creates a 2D Gaussian filter with a partial derivative along rows.

Errorcreate_2d_gaussian_dy_filter_f (Matrix_f **h_out, float row_sigma, float col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a single precision 2D Gaussian filter with a partial derivative in the y direction (row).
Errorcreate_2d_gaussian_dy_filter_d (Matrix_d **h_out, double row_sigma, double col_sigma, uint32_t num_rows, uint32_t num_cols)
 Creates a double precision 2D Gaussian filter with a partial derivative in the y direction (row).

Detailed Description

Definitions for matrix filters.

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

Definition in file 2d.c.


Define Documentation

#define PI   3.14159265358979323846

Estimate of pi.

Definition at line 61 of file 2d.c.


Function Documentation

void create_sobel_x_filter_f ( Matrix_f **  sobel_out)

Creates a single precision Sobel operator for the x direction.

The x direction is across matrix columns.

Parameters:
sobel_outResult parameter. If *sobel_out is NULL, a matrix is allocated; otherwise its space is re-used.
Note:
Does not scale the operator.

Definition at line 79 of file 2d.c.

void create_sobel_x_filter_d ( Matrix_d **  sobel_out)

Creates a double precision Sobel operator for the x direction.

The x direction is across matrix columns.

Parameters:
sobel_outResult parameter. If *sobel_out is NULL, a matrix is allocated; otherwise its space is re-used.
Note:
Does not scale the operator.

Definition at line 102 of file 2d.c.

void create_sobel_y_filter_f ( Matrix_f **  sobel_out)

Creates a single precision Sobel operator for the y direction.

The y direction is across matrix rows.

Parameters:
sobel_outResult parameter. If *sobel_out is NULL, a matrix is allocated; otherwise its space is re-used.
Note:
Does not scale the operator.

Definition at line 137 of file 2d.c.

void create_sobel_y_filter_d ( Matrix_d **  sobel_out)

Creates a double precision Sobel operator for the y direction.

The y direction is across matrix rows.

Parameters:
sobel_outResult parameter. If *sobel_out is NULL, a matrix is allocated; otherwise its space is re-used.
Note:
Does not scale the operator.

Definition at line 160 of file 2d.c.

Error* create_LoG_filter_f ( Matrix_f **  LoG_out,
float  sigma 
)

Creates a single precision Laplacian of Gaussian filter.

Parameters:
LoG_outResult parameter. If *LoG_out is NULL, a matrix is allocated; otherwise its space is re-used.
sigmaSigma to the Laplacian.
Returns:
On success, NULL is returned. On error, an Error is returned and *LoG_out is freed and set to NULL.
Note:
Does not scale the operator.
The dimensions of the filter will be square and odd.

Definition at line 201 of file 2d.c.

Error* create_auto_2d_gaussian_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma 
)

Creates a single precision 2D Gaussian filter automatically sized.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Does not normalize the sum of the filter to 1.
The dimensions of the filter will be odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 268 of file 2d.c.

Error* create_auto_2d_gaussian_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma 
)

Creates a double precision 2D Gaussian filter automatically sized.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Does not normalize the sum of the filter to 1.
The dimensions of the filter will be odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 300 of file 2d.c.

Error* create_2d_gaussian_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a single precision 2D Gaussian filter.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Does not normalize the sum of the filter to 1.
If integrate_gaussian_pdf_d() function is not available, then the gaussian_pdf_d() is used for each value of the matrix.
Dimensions must be > 0.

Definition at line 348 of file 2d.c.

Error* create_2d_gaussian_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a double precision 2D Gaussian filter.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Does not normalize the sum of the filter to 1.
If integrate_gaussian_pdf_d() function is not available, then the gaussian_pdf_d() is used for each value of the matrix.
Dimensions must be > 0.

Definition at line 447 of file 2d.c.

Error* create_auto_2d_gaussian_dx_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma 
)

Creates a single precision 2D Gaussian filter with a partial derivative in the x-direction (column) automatically sized.

The x direction is across matrix columns.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
The dimensions of the filter will be square and odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 555 of file 2d.c.

Error* create_auto_2d_gaussian_dx_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma 
)

Creates a double precision 2D Gaussian filter with a partial derivative in the x-direction (column) automatically sized.

The x direction is across matrix columns.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
The dimensions of the filter will be square and odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 587 of file 2d.c.

Error* create_2d_gaussian_dx_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a single precision 2D Gaussian filter with a partial derivative in the x-direction (column).

The x direction is across matrix columns.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Dimensions must be > 0.

Definition at line 632 of file 2d.c.

Error* create_2d_gaussian_dx_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a double precision 2D Gaussian filter with a partial derivative in the x-direction (column).

The x direction is across matrix columns.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Dimensions must be > 0.

Definition at line 699 of file 2d.c.

Error* create_auto_2d_gaussian_dy_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma 
)

Creates a single precision 2D Gaussian filter with a partial derivative in the y-direction (row) automatically sized.

The y direction is across matrix rows.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
The dimensions of the filter will be square and odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 779 of file 2d.c.

Error* create_auto_2d_gaussian_dy_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma 
)

Creates a double precision 2D Gaussian filter with a partial derivative in the y-direction (row) automatically sized.

The y direction is across matrix rows.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
The dimensions of the filter will be square and odd and enough to contain at least 6 stdev of the Gaussian.

Definition at line 811 of file 2d.c.

Error* create_2d_gaussian_dy_filter_f ( Matrix_f **  h_out,
float  row_sigma,
float  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a single precision 2D Gaussian filter with a partial derivative in the y direction (row).

The y direction is across matrix rows.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Dimensions must be > 0.

Definition at line 856 of file 2d.c.

Error* create_2d_gaussian_dy_filter_d ( Matrix_d **  h_out,
double  row_sigma,
double  col_sigma,
uint32_t  num_rows,
uint32_t  num_cols 
)

Creates a double precision 2D Gaussian filter with a partial derivative in the y direction (row).

The y direction is across matrix rows.

Parameters:
h_outResult parameter. If *h_out is NULL, a matrix is allocated; otherwise its space is re-used.
row_sigmaSigma to the Gaussian along rows.
col_sigmaSigma to the Gaussian along columns.
num_rowsNumber of rows.
num_colsNumber of columns.
Returns:
On success, NULL is returned. On error, an Error is returned and *h_out is freed and set to NULL.
Note:
Dimensions must be > 0.

Definition at line 923 of file 2d.c.