Figure 6-6. On the left are three shapes that we want to recognize as “square.” The problem is, they look
very different. One is much larger than the others and another is rotated. The log-polar transform appears
on the right in
Figure 6-6. Observe that size differences in the (𝑥, 𝑦) plane are converted to shifts along the lo g !(𝑟) axis of
the log-polar plane and that the rotation differences are converted to shifts along the 𝜃-axis in the log-polar
plane. If we take the transformed center of each transformed square in the log-polar plane and then re-
center that point to a certain fixed position, then all the squares will show up identically in the log-polar
plane. This yields a type of invariance to two-dimensional rotation and scaling.
12
Figure 6-6: Log-polar transform of rotated and scaled squares: size goes to a shift on the 𝑙𝑜𝑔 𝑟 axis and
rotation to a shift on the 𝜃-axis
cv::logPolar()
The OpenCV function for a log-polar transform is cv::logPolar():
void cv::logPolar(
cv::InputArray src, // Input image
cv::OutputArray dst, // Output image
cv::Point2f center, // Center of transform
double m, // Scale factor
int flags = cv::INTER_LINEAR
| cv::WARP_FILL_OUTLIERS // interpolation and fill modes
);
12
In Chapter 13, we‘ll learn about recognition. For now, simply note that it wouldn‘t be a good idea to derive a log-
polar transform