/* Makes an identity matrix (mat_ij = i == j) */
CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) );
+/* Fills matrix with given range of numbers */
+CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end );
+
/* Calculates covariation matrix for a set of vectors */
/* transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */
#define CV_COVAR_SCRAMBLED 0
#define CV_PCA_DATA_AS_ROW 0
#define CV_PCA_DATA_AS_COL 1
#define CV_PCA_USE_AVG 2
-#define CV_PCA_RET_SDV 4
-#define CV_PCA_RET_EVAL 0
-
CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean,
CvArr* eigenvals, CvArr* eigenvects, int flags );
const CvArr* mask CV_DEFAULT(NULL) );
CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst,
- double a, double b CV_DEFAULT(0.),
+ double a CV_DEFAULT(1.), double b CV_DEFAULT(0.),
int norm_type CV_DEFAULT(CV_L2),
const CvArr* mask CV_DEFAULT(NULL) );
if( len <= in_count )
covar_flags |= CV_COVAR_NORMAL;
+ if( flags & CV_PCA_USE_AVG )
+ covar_flags |= CV_COVAR_USE_AVG;
+
CV_CALL( tmp_cov = cvCreateMat( count, count, CV_64F ));
CV_CALL( tmp_evals = cvCreateMat( 1, count, CV_64F ));
CV_CALL( tmp_evects = cvCreateMat( count, count, CV_64F ));
}
+CV_IMPL CvArr*
+cvRange( CvArr* arr, double start, double end )
+{
+ int ok = 0;
+
+ CV_FUNCNAME( "cvRange" );
+
+ __BEGIN__;
+
+ CvMat stub, *mat = (CvMat*)arr;
+ double delta;
+ int type, step;
+ double val = start;
+ int i, j;
+ int rows, cols;
+
+ if( !CV_IS_MAT(mat) )
+ CV_CALL( mat = cvGetMat( mat, &stub) );
+
+ rows = mat->rows;
+ cols = mat->cols;
+ type = CV_MAT_TYPE(mat->type);
+ delta = (end-start)/(rows*cols);
+
+ if( CV_IS_MAT_CONT(mat->type) )
+ {
+ cols *= rows;
+ rows = 1;
+ step = 1;
+ }
+ else
+ step = mat->step / CV_ELEM_SIZE(type);
+
+ if( type == CV_32SC1 )
+ {
+ int* idata = mat->data.i;
+ int ival = cvRound(val), idelta = cvRound(delta);
+
+ if( fabs(val - ival) < DBL_EPSILON &&
+ fabs(delta - idelta) < DBL_EPSILON )
+ {
+ for( i = 0; i < rows; i++, idata += step )
+ for( j = 0; j < cols; j++, ival += idelta )
+ idata[j] = ival;
+ }
+ else
+ {
+ for( i = 0; i < rows; i++, idata += step )
+ for( j = 0; j < cols; j++, val += delta )
+ idata[j] = cvRound(val);
+ }
+ }
+ else if( type == CV_32FC1 )
+ {
+ float* fdata = mat->data.fl;
+ for( i = 0; i < rows; i++, fdata += step )
+ for( j = 0; j < cols; j++, val += delta )
+ fdata[j] = (float)val;
+ }
+ else
+ CV_ERROR( CV_StsUnsupportedFormat, "The function only supports 32sC1 and 32fC1 datatypes" );
+
+ ok = 1;
+
+ __END__;
+
+ return ok ? arr : 0;
+}
+
/* End of file. */