MCPcopy Create free account
hub / github.com/creatale/node-dv / norm

Function norm

deps/opencv/modules/core/src/matrix.cpp:4133–4180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4131
4132
4133double norm( const SparseMat& src, int normType )
4134{
4135 SparseMatConstIterator it = src.begin();
4136
4137 size_t i, N = src.nzcount();
4138 normType &= NORM_TYPE_MASK;
4139 int type = src.type();
4140 double result = 0;
4141
4142 CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 );
4143
4144 if( type == CV_32F )
4145 {
4146 if( normType == NORM_INF )
4147 for( i = 0; i < N; i++, ++it )
4148 result = std::max(result, std::abs((double)*(const float*)it.ptr));
4149 else if( normType == NORM_L1 )
4150 for( i = 0; i < N; i++, ++it )
4151 result += std::abs(*(const float*)it.ptr);
4152 else
4153 for( i = 0; i < N; i++, ++it )
4154 {
4155 double v = *(const float*)it.ptr;
4156 result += v*v;
4157 }
4158 }
4159 else if( type == CV_64F )
4160 {
4161 if( normType == NORM_INF )
4162 for( i = 0; i < N; i++, ++it )
4163 result = std::max(result, std::abs(*(const double*)it.ptr));
4164 else if( normType == NORM_L1 )
4165 for( i = 0; i < N; i++, ++it )
4166 result += std::abs(*(const double*)it.ptr);
4167 else
4168 for( i = 0; i < N; i++, ++it )
4169 {
4170 double v = *(const double*)it.ptr;
4171 result += v*v;
4172 }
4173 }
4174 else
4175 CV_Error( CV_StsUnsupportedFormat, "Only 32f and 64f are supported" );
4176
4177 if( normType == NORM_L2 )
4178 result = std::sqrt(result);
4179 return result;
4180}
4181
4182void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _minidx, int* _maxidx )
4183{

Callers 8

convert.cppFile · 0.70
arrowedLineFunction · 0.70
normalizeFunction · 0.70
stat.cppFile · 0.70
normMethod · 0.70
cvNormFunction · 0.70
buildFeatureListMethod · 0.50
PSNRMethod · 0.50

Calls 6

sqrtFunction · 0.85
nzcountMethod · 0.80
maxFunction · 0.70
absFunction · 0.70
beginMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected