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

Function cvLinearPolar

deps/opencv/modules/imgproc/src/imgwarp.cpp:4296–4384  ·  view source on GitHub ↗

Linear-Polar Transform J.L. Blanco, Apr 2009 ****************************************************************************************/

Source from the content-addressed store, hash-verified

4294 J.L. Blanco, Apr 2009
4295 ****************************************************************************************/
4296CV_IMPL
4297void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
4298 CvPoint2D32f center, double maxRadius, int flags )
4299{
4300 cv::Ptr<CvMat> mapx, mapy;
4301
4302 CvMat srcstub, *src = (CvMat*)srcarr;
4303 CvMat dststub, *dst = (CvMat*)dstarr;
4304 CvSize ssize, dsize;
4305
4306 src = cvGetMat( srcarr, &srcstub,0,0 );
4307 dst = cvGetMat( dstarr, &dststub,0,0 );
4308
4309 if( !CV_ARE_TYPES_EQ( src, dst ))
4310 CV_Error( CV_StsUnmatchedFormats, "" );
4311
4312 ssize.width = src->cols;
4313 ssize.height = src->rows;
4314 dsize.width = dst->cols;
4315 dsize.height = dst->rows;
4316
4317 mapx = cvCreateMat( dsize.height, dsize.width, CV_32F );
4318 mapy = cvCreateMat( dsize.height, dsize.width, CV_32F );
4319
4320 if( !(flags & CV_WARP_INVERSE_MAP) )
4321 {
4322 int phi, rho;
4323
4324 for( phi = 0; phi < dsize.height; phi++ )
4325 {
4326 double cp = cos(phi*2*CV_PI/dsize.height);
4327 double sp = sin(phi*2*CV_PI/dsize.height);
4328 float* mx = (float*)(mapx->data.ptr + phi*mapx->step);
4329 float* my = (float*)(mapy->data.ptr + phi*mapy->step);
4330
4331 for( rho = 0; rho < dsize.width; rho++ )
4332 {
4333 double r = maxRadius*(rho+1)/dsize.width;
4334 double x = r*cp + center.x;
4335 double y = r*sp + center.y;
4336
4337 mx[rho] = (float)x;
4338 my[rho] = (float)y;
4339 }
4340 }
4341 }
4342 else
4343 {
4344 int x, y;
4345 CvMat bufx, bufy, bufp, bufa;
4346 const double ascale = ssize.height/(2*CV_PI);
4347 const double pscale = ssize.width/maxRadius;
4348
4349 cv::AutoBuffer<float> _buf(4*dsize.width);
4350 float* buf = _buf;
4351
4352 bufx = cvMat( 1, dsize.width, CV_32F, buf );
4353 bufy = cvMat( 1, dsize.width, CV_32F, buf + dsize.width );

Callers

nothing calls this directly

Calls 6

cvGetMatFunction · 0.85
cvCreateMatFunction · 0.85
cvMatFunction · 0.85
cvCartToPolarFunction · 0.85
cvRemapFunction · 0.85
cvScalarAllFunction · 0.85

Tested by

no test coverage detected