Back to Ccv

lib/ccv_util.c

site/0.6/lib/ccv-util/index.html

latest6.2 KB
Original Source

lib/ccv_util.c

ccv_get_dense_matrix

ccv_dense_matrix_t* ccv_get_dense_matrix(ccv_matrix_t* mat)

Check and get dense matrix from general matrix structure.

  • mat : a general matrix.

ccv_get_sparse_matrix

ccv_sparse_matrix_t* ccv_get_sparse_matrix(ccv_matrix_t* mat)

Check and get sparse matrix from general matrix structure.

  • mat : a general matrix.

ccv_visualize

void ccv_visualize(ccv_matrix_t* a, ccv_matrix_t** b, int type)

Convert a input matrix into a matrix within visual range, so that one can output it into PNG file for inspection.

  • a : the input matrix.
  • b : the output matrix.
  • type : the type of output matrix, if 0, ccv will try to match the input matrix for appropriate type.

ccv_zero

void ccv_zero(ccv_matrix_t* mat)

Zero out a given matrix.

  • mat : the given matrix.

ccv_any_nan

int ccv_any_nan(ccv_matrix_t *a)

Check if any nan value in the given matrix, and return its position.

  • a : the given matrix.

ccv_flatten

void ccv_flatten(ccv_matrix_t* a, ccv_matrix_t** b, int type, int flag)

If a given matrix has multiple channels, this function will compute a new matrix that each cell in the new matrix is the sum of all channels in the same cell of the given matrix.

  • a : the input matrix.
  • b : the output matrix.
  • type : the type of output matrix, if 0, ccv will try to match the input matrix for appropriate type.
  • flag : ccv reserved this for now.

ccv_shift

void ccv_shift(ccv_matrix_t* a, ccv_matrix_t** b, int type, int lr, int rr)

Compute a new matrix that each element is first left shifted and then right shifted.

  • a : the input matrix.
  • b : the output matrix.
  • type : the type of output matrix, if 0, ccv will try to match the input matrix for appropriate type.
  • lr : left shift amount.
  • rr : right shift amount.

ccv_get_sparse_matrix_vector

ccv_dense_vector_t* ccv_get_sparse_matrix_vector(ccv_sparse_matrix_t* mat, int index)

Get vector for a sparse matrix.

  • mat : the sparse matrix.
  • index : the index of that vector.

ccv_get_sparse_matrix_cell

ccv_matrix_cell_t ccv_get_sparse_matrix_cell(ccv_sparse_matrix_t* mat, int row, int col)

Get cell from a sparse matrix.

  • mat : the sparse matrix.
  • row : the row index.
  • col : the column index.

ccv_set_sparse_matrix_cell

void ccv_set_sparse_matrix_cell(ccv_sparse_matrix_t* mat, int row, int col, void* data)

Set cell for a sparse matrix.

  • mat : the sparse matrix.
  • row : the row index.
  • col : the column index.
  • data : the data pointer.

ccv_compress_sparse_matrix

void ccv_compress_sparse_matrix(ccv_sparse_matrix_t* mat, ccv_compressed_sparse_matrix_t** csm)

Transform a sparse matrix into compressed representation.

  • mat : the sparse matrix.
  • csm : the compressed matrix.

ccv_decompress_sparse_matrix

void ccv_decompress_sparse_matrix(ccv_compressed_sparse_matrix_t* csm, ccv_sparse_matrix_t** smt)

Transform a compressed matrix into a sparse matrix.

  • csm : the compressed matrix.
  • smt : the sparse matrix.

ccv_matrix_eq

int ccv_matrix_eq(ccv_matrix_t* a, ccv_matrix_t* b)

Compare if two matrix are equal (with type). Return 0 if it is.

  • a : the input matrix a.
  • b : the input matrix b.

ccv_slice

void ccv_slice(ccv_matrix_t* a, ccv_matrix_t** b, int btype, int y, int x, int rows, int cols)

Slice an input matrix given x, y and row, column size.

  • a : the input matrix.
  • b : the output matrix.
  • btype : the type of output matrix, if 0, ccv will use the input matrix type.
  • y : y coordinate.
  • x : x coordinate.
  • rows : row size of targeted matrix.
  • cols : column size of targeted matrix.

ccv_border

void ccv_border(ccv_matrix_t* a, ccv_matrix_t** b, ccv_margin_t margin)

Add border to the input matrix.

  • a : the input matrix.
  • b : the output matrix.
  • margin : left, top, right, bottom width for the border.

ccv_move

void ccv_move(ccv_matrix_t* a, ccv_matrix_t** b, int btype, int y, int x)

Offset input matrix by x, y.

  • a : the input matrix.
  • b : the output matrix.
  • btype : the type of output matrix, if 0, ccv will use the input matrix type.
  • y : b(0, 0) = a(x, y).
  • x : b(0, 0) = a(x, y).

ccv_array_new

ccv_array_t* ccv_array_new(int rnum, int rsize)

Create a new, self-growing array.

  • rnum : the initial capacity of the array.
  • rsize : the size of each element in the array.

ccv_array_push

void ccv_array_push(ccv_array_t* array, void* r)

Push a new element into the array.

  • array : the array.
  • r : the pointer to new element, it will then be copied into the array.

ccv_array_zero

void ccv_array_zero(ccv_array_t* array)

Zero out the array, it won’t change the array->rnum however.

  • array : the array.

ccv_array_clear

void ccv_array_clear(ccv_array_t* array)

Clear the array, it will reset the array->rnum to 0.

  • array : the array.

ccv_array_free

void ccv_array_free(ccv_array_t* array)

Free up the array.

  • array : the array.

ccv_array_group

int ccv_array_group(ccv_array_t* array, ccv_array_t** index, ccv_array_group_f gfunc, void* data)

Group elements in the array from its similarity.

  • array : the array.
  • index : the output index, same group element will have the same index.
  • gfunc : int ccv_array_group_f(const void* a, const void* b, void* data). Return 1 if a and b are in the same group.
  • data : any extra user data.

ccv_contour_new

ccv_contour_t* ccv_contour_new(int set)

Create a new contour object.

  • set : the initial capacity of the contour.

ccv_contour_push

void ccv_contour_push(ccv_contour_t* contour, ccv_point_t point)

Push a point into the contour object.

  • contour : the contour.
  • point : the point.

ccv_contour_free

void ccv_contour_free(ccv_contour_t* contour)

Free up the contour object.

  • contour : the contour.

‹ back

comments powered by Disqus