Learning Opencv 3 —— 四章 SparseMat 介绍

Opencv SparseMat 介绍

ExampleDescription
cv::SparseMat sm;Create a sparse matrix without initialization
cv::SparseMat sm( 3, sz, CV_32F );Create a three-dimensional sparse matrix with dimensions given by the array sz of type float
cv::SparseMat sm( sm0 );Create a new sparse matrix that is a copy of the existing sparse matrix sm0
cv::SparseMat( m0, try1d );Create a sparse matrix from an existing dense matrix m0; if the bool try1d is true, convert m0 to a one-dimensional sparse matrix if the dense matrix was n × 1 or 1 × n
cv::SparseMat( &old_sparse_mat );Create a new sparse matrix from a pointer to a pre–version 2.1 C-style sparse matrix of type CvSparseMat
CvSparseMat* old_sm = (cv::SparseMat*) sm;Cast operator creates a pointer to a pre–version 2.1 C-style sparse matrix; that CvSparseMat object is created and all data is copied into it, and then its pointer is returned
size_t n = sm.nzcount();Return the number of nonzero elements in sm
size_t h = sm.hash( i0 );
size_t h = sm.hash( i0, i1 );
size_t h = sm.hash( i0, i1, i2 );
size_t h = sm.hash( idx );
Return the hash value for element i0 in a one-dimensional sparse matrix; i0, i1 in a two-dimensional sparse matrix; i0, i1, i2 in a threedimensional sparse matrix; or the element indicated by the array of integers idx in an n-dimensional sparse matrix
sm.ref<float>( i0 ) = f0;
sm.ref<float>( i0, i1 ) = f0;
sm.ref<float>( i0, i1, i2 ) = f0;
sm.ref<float>( idx ) = f0;
Assign the value f0 to element i0 in a one-dimensional sparse matrix; i0, i1 in a two-dimensional sparse matrix; i0, i1, i2 in a threedimensional sparse matrix; or the element indicated by the array of integers idx in an n-dimensional sparse matrix
f0 = sm.value<float>( i0 );
f0 = sm.value<float>( i0, i1 );
f0 = sm.value<float>( i0, i1, i2 );
f0 = sm.value<float>( idx );
Assign the value to f0 from element i0 in a one-dimensional sparse matrix; i0, i1 in a two-dimensional sparse matrix; i0, i1, i2 in a threedimensional sparse matrix; or the element indicated by the array of integers idx in an n-dimensional sparse matrix
p0 = sm.find<float>( i0 );
p0 = sm.find<float>( i0, i1 );
p0 = sm.find<float>( i0, i1, i2 );
p0 = sm.find<float>( idx );
Assign to p0 the address of element i0 in a one-dimensional sparse matrix; i0, i1 in a two-dimensional sparse matrix; i0, i1, i2 in a threedimensional sparse matrix; or the element indicated by the array of integers idx in an n-dimensional sparse matrix
sm.erase( i0, i1, &hashval );
sm.erase( i0, i1, i2, &hashval );
sm.erase( idx, &hashval );
Remove the element at (i0, i1) in a two-dimensional sparse matrix; at (i0, i1, i2) in a three-dimensional sparse matrix; or the element
indicated by the array of integers idx in an n-dimensional sparse matrix. If hashval is not NULL, use the provided value instead of computing it
cv::SparseMatIterator<float> it = sm.begin<float>();Create a sparse matrix iterator it and point it at the first value of the floating-point array sm
cv::SparseMatIterator<uchar> it_end
= sm.end<uchar>();
Create a sparse matrix iterator it_end and initialize it to the value
succeeding the final value in the byte array sm

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值