IPSDK 4.2
IPSDK : Image Processing Software Development Kit
Polar to cartesian transformation
xImg,yImg = polarToCartesianImg (inRhoImg,inThetaImg)

Detailed Description

computation of the polar to cartesian coordinates transformation

This algorithm computes the polar to cartesian coordinates transformations of input images $InRhoImg$ and $InThetaImg$ :

\[ OutXImg[i] = InRhoImg[i] \times cos(InThetaImg[i]) \]

and

\[ OutYImg[i] = InRhoImg[i] \times sin(InThetaImg[i]) \]

For more informations report to Points and vectors 2d representation

See also
https://en.wikipedia.org/wiki/Polar_coordinate_system

Example of Python code :

Example imports

import PyIPSDK
import PyIPSDK.IPSDKIPLArithmetic as arithm

Code Example

# opening of input images
inImg = PyIPSDK.loadTiffImageFile(inputImgPath)
# gaussian gradient filter 2d computation
# (requesting floating point output images)
gxImg = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Real32,
inImg.getSizeX(), inImg.getSizeY())
gyImg = PyIPSDK.createImage(PyIPSDK.eImageBufferType.eIBT_Real32,
inImg.getSizeX(), inImg.getSizeY())
filter.gaussianGradient2dImg(inImg, 1.5, 1.5, PyIPSDK.createGaussianCoverage(0.997, 2), gxImg, gyImg)
# computation of cartesian to polar transformation
rhoImg, thetaImg = arithm.cartesianToPolarImg(gxImg, gyImg)
# come back to cartesian representation
# (ie outXImg == gxImg and outYImg == gyImg)
outXImg, outYImg = arithm.polarToCartesianImg(rhoImg, thetaImg)

Example of C++ code :

Example informations

Header file

#include <IPSDKIPL/IPSDKIPLArithmetic/Processor/PolarToCartesianImg/PolarToCartesianImg.h>

Code Example

// opening input image
ImagePtr pInImg = loadTiffImageFile(inputImgPath);
// computation of associated gradient image
// (requesting floating point output images)
ImageGeometryPtr pGradientGeometry = geometry2d(eImageBufferType::eIBT_Real32,
pInImg->getSizeX(), pInImg->getSizeY());
MemoryImagePtr pGxImg(boost::make_shared<MemoryImage>());
pGxImg->init(*pGradientGeometry);
MemoryImagePtr pGyImg(boost::make_shared<MemoryImage>());
pGyImg->init(*pGradientGeometry);
gaussianGradient2dImg(pInImg, 1.5f, 1.5f, createGaussianCoverage(0.997f, 2), pGxImg, pGyImg);
// computation of cartesian to polar transformation
PolarImg polarData = cartesianToPolarImg(pGxImg, pGyImg);
// come back to cartesian representation
// (ie *pOutXImg == *pGxImg and *pOutYImg == *pGyImg)
CartesianImg cartesianData = polarToCartesianImg(polarData._pRhoImg, polarData._pThetaImg);
ImagePtr pOutXImg = cartesianData._pXImg;
ImagePtr pOutYImg = cartesianData._pYImg;