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

Function phase

deps/opencv/modules/core/src/mathfuncs.cpp:385–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383
384
385void phase( InputArray src1, InputArray src2, OutputArray dst, bool angleInDegrees )
386{
387 Mat X = src1.getMat(), Y = src2.getMat();
388 int type = X.type(), depth = X.depth(), cn = X.channels();
389 CV_Assert( X.size == Y.size && type == Y.type() && (depth == CV_32F || depth == CV_64F));
390 dst.create( X.dims, X.size, type );
391 Mat Angle = dst.getMat();
392
393 const Mat* arrays[] = {&X, &Y, &Angle, 0};
394 uchar* ptrs[3];
395 NAryMatIterator it(arrays, ptrs);
396 cv::AutoBuffer<float> _buf;
397 float* buf[2] = {0, 0};
398 int j, k, total = (int)(it.size*cn), blockSize = total;
399 size_t esz1 = X.elemSize1();
400
401 if( depth == CV_64F )
402 {
403 blockSize = std::min(blockSize, ((BLOCK_SIZE+cn-1)/cn)*cn);
404 _buf.allocate(blockSize*2);
405 buf[0] = _buf;
406 buf[1] = buf[0] + blockSize;
407 }
408
409 for( size_t i = 0; i < it.nplanes; i++, ++it )
410 {
411 for( j = 0; j < total; j += blockSize )
412 {
413 int len = std::min(total - j, blockSize);
414 if( depth == CV_32F )
415 {
416 const float *x = (const float*)ptrs[0], *y = (const float*)ptrs[1];
417 float *angle = (float*)ptrs[2];
418 FastAtan2_32f( y, x, angle, len, angleInDegrees );
419 }
420 else
421 {
422 const double *x = (const double*)ptrs[0], *y = (const double*)ptrs[1];
423 double *angle = (double*)ptrs[2];
424 for( k = 0; k < len; k++ )
425 {
426 buf[0][k] = (float)x[k];
427 buf[1][k] = (float)y[k];
428 }
429
430 FastAtan2_32f( buf[1], buf[0], buf[0], len, angleInDegrees );
431 for( k = 0; k < len; k++ )
432 angle[k] = buf[0][k];
433 }
434 ptrs[0] += len*esz1;
435 ptrs[1] += len*esz1;
436 ptrs[2] += len*esz1;
437 }
438 }
439}
440
441
442void cartToPolar( InputArray src1, InputArray src2,

Callers 1

cvCartToPolarFunction · 0.85

Calls 9

FastAtan2_32fFunction · 0.85
minFunction · 0.70
getMatMethod · 0.45
typeMethod · 0.45
depthMethod · 0.45
channelsMethod · 0.45
createMethod · 0.45
elemSize1Method · 0.45
allocateMethod · 0.45

Tested by

no test coverage detected