# Irregular-shaped regions of interest

**URL:** <https://forum.commonvisionblox.com/t/irregular-shaped-regions-of-interest/423>\
**Category:** Programming Questions\
**Tags:** roi, aoi, processing\
**Created:** [April 19, 2018, 12:33pm UTC](https://forum.commonvisionblox.com/t/irregular-shaped-regions-of-interest/423 "2018-04-19T12:33:29Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![illusive](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/illusive/32/61_2.png) [@illusive](https://forum.commonvisionblox.com/u/illusive)\
**Post date:** [July 6, 2018, 3:39pm UTC](https://forum.commonvisionblox.com/t/irregular-shaped-regions-of-interest/423/7 "2018-07-06T15:39:12Z")

</div>

… 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:

```auto
// 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](https://forum.commonvisionblox.com/t/introducing-experimental-cvb-net-cvb-and-cvbpy-api/205?u=illusive)) 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).

---

_[View the full topic](https://forum.commonvisionblox.com/t/irregular-shaped-regions-of-interest/423)._
