… and the conversion of coordinates is a matter of not so very advanced math: Every pixel (or, to be precise, the center of every pixel…) in the result image of polar unwrap corresponds to an angle and a radius (in this case read “distance to polar unwrap center”). If you still know the parameters CX
, CY
, Alpha0
, RMin
, RMax
(and optionally AlphaTotal
) that have been used in the CreatePolarImage
(Ex
) call that did the unwrap then determining the angle and the radius is fairly straigthforward:
// assumptions:
// imgUnwrapped = result image of polar unwrap operation
// xu, yu = coordinates in imgUnwrapped for which to calculate x, y in the original image
// input parameters to the CreatePolarImageEx call that created imgUnwrapped:
// cx, cy, alpha0, alphaTotal, rMin, rMax
auto uMaxX = static_cast<double>(ImageWidth(imgUnwrapped) - 1);
auto uMaxY = static_cast<double>(ImageHeight(imgUnwrapped) - 1);
auto alpha = static_cast<double>(xu)/uMaxX * alphaTotal + alpha0;
auto r = static_cast<double>(yu)/uMaxY * (rMax - rMin) + rMin;
auto x = cx + r * cos(alpha);
auto y = cy + r * sin(alpha);
If you used CreatePolarImage
instead of CreatePolarImageEx
then alphaTotal
simply amounts to 360°. In the object-oriented APIs for C#, C++ and Python (see here) these two functions correspond to the PolarTransform
extension/static member method on the Image
object (C# and C++) or the cvb.polar_transform
function (Python).